Running Cron jobs in jails

Status
Not open for further replies.

Tony Self

Contributor
Joined
Jan 30, 2017
Messages
130
Hi, I am still pretty new to FreeNAS and there are things i don't fully understand yet so I would appreciate some guidance from our more experienced users.

I have recently created a jail for RClone so I can begin to sync my media library with my Google Drive. I found some instructions in the forum and successfully created the jail.

My experience with RClone itself is pretty limited as well, but by testing on one of my smallest media folders I have managed to start syncing the folder. I started testing on the command line within the jail, but ultimately I want to create a series of Cron jobs I can execute even when I am remote to my server.

As far as I understand to run a Cron job in a jail I need to prefix the command line with "jexec n", where n is the number of the jail. I have tested this from the shell adding in the -v verbose option and have successfully synced over 200 files now.

I have now created a Cron job running as root to execute the following command
"jexec 2 rclone sync --exclude-from /root/exclude-list.txt /media/miniseries gdrive:plex/mini"
I have the cron job currently disabled so I can just run it by clicking on the "Run Now" button.

Having kicked off the job, how can I tell whether the job is successfully running? Is there anyway to get feedback that the command is doing it's job?

Regards

Tony Self
 

Tony Self

Contributor
Joined
Jan 30, 2017
Messages
130
No, haven't solved this issue yet. I have just been running the commands from the shell. I do want to get this working as I will only be able to access my server remotely in a couple of weeks for over 6 weeks and I don't want to waste my bandwidth


Sent from my iPad using Tapatalk
 
Joined
Dec 2, 2015
Messages
730
One option might be to have the cron job call a shell script that contained the desired command instead of putting the command directly in cron. The shell script could email a status report when it starts, and another one when it finishes.

I'm no expert, so I won't try to propose a script. You could slavishly copy the email related portions from something like the zpool_report.sh script here.
 

Tony Self

Contributor
Joined
Jan 30, 2017
Messages
130
One option might be to have the cron job call a shell script that contained the desired command instead of putting the command directly in cron. The shell script could email a status report when it starts, and another one when it finishes.

I'm no expert, so I won't try to propose a script. You could slavishly copy the email related portions from something like the zpool_report.sh script here.
I like the sound of that. Thanks for the idea, I will work on that. I have found that rclone can write to a log, so a script that can email the log to me is probably the ideal solution.
 

Tony Self

Contributor
Joined
Jan 30, 2017
Messages
130
Having left this problem for a while, I have come back to it now that my scripting skills have improved.

I have discovered the problem with RClone. I had no problem running the script from the command line either in the jail or from outside, but as soon as I tried to run it as a Cron job, the script would fail.

It turns out when you run from the command line RClone finds your rclone.conf automatically. However when it's being called from within a Cron job it doesn't. So the solution is to add the --config option to the RClone command pointing to the rclone.conf.

I now have by RClone sync jobs running on a regular basis.
 
Status
Not open for further replies.
Top