Cron an rclone task configured inside jail

Status
Not open for further replies.

pixel8383

Explorer
Joined
Apr 19, 2018
Messages
80
Hello, I am trying to setup my .sh file in order to use the FreeNAS cron-managment GUI. I want to execute an rclone task inside a jail and save the stOut buffer to a variable that I will mail when the task is terminated.

Actually my code is the following:

Code:
#!/bin/sh
SOURCEPATH="MyFTP:/home/public_html/"
DESTPATH=" /mnt/Backup/MyFTP/public_html/"
FILTERS="- cache/supercache/**"
MSG="Starting sync..."
output="$MSG"$'\n'"$(jexec rclone rclone sync $SOURCEPATH $DESTPATH --filter "$FILTERS" -v 2>&1)"
MSG="MyFTP SFTP sync completed"
output="$output"$'\n'"$MSG"
MSG="The scheduled task completed successfully"
output="$output"$'\n'"$MSG"
echo "$output" | mail -s "FreeNAS - RClone: MyFTP SFTP Sync" "<my-email>"

It works pretty well if I execute this .sh file via SSH. When I try to start my cron, instead, I get the following error:

Code:
Starting sync...
2018/06/22 17:12:11 NOTICE: Config file "/.config/rclone/rclone.conf" not found - using defaults
2018/06/22 17:12:11 Failed to create file system for "MyFTP:/home/public_html/": didn't find section in config file
MyFTP SFTP sync completed
The scheduled task completed successfully


It seems like the cron process will get stuck when has to execute the $(jexec ...) command. It will not try to use the jail but tries to locate a global configuration (outside my rclone jail). This way the task cannot be executed.

What can I do to get the same result?

Thanks,
Emanuele
 

PhilipS

Contributor
Joined
May 10, 2016
Messages
179
Could you specify the path to the rclone config file with --config? cron doesn't load any user profile/environment settings, so that may be your issue.
 

pixel8383

Explorer
Joined
Apr 19, 2018
Messages
80
Hello Philips, thanks for your answer. Cron is able to complete the job until I don’t use $(jexec ...) but I just execute the command without nesting it (to be clear, without using the $() format). So it is like the execution of $ fail somehow. I don’t get why.
 
Status
Not open for further replies.
Top