use cron to run jail commands

nikkon

Contributor
Joined
Dec 16, 2012
Messages
171
Hi all,

It may sound stupid, but I could not find this in the docs. I intend to periodically run commands into each and every jail.
Cron seems to be the easy way.
Can you please advise? a simple example will help me understand
Thanks
 

Samuel Tai

Never underestimate your own stupidity
Moderator
Joined
Apr 24, 2020
Messages
5,399
Cron already runs in each jail. Just crontab -e as root in each jail. See the crontab(5) man page for FreeBSD for examples.
 

nikkon

Contributor
Joined
Dec 16, 2012
Messages
171
I was willing to define cron jobs in freenas to run tasks inside the jail. If I destroy/recreate the jails, I don't wanna lose the jobs
 

Patrick M. Hausen

Hall of Famer
Joined
Nov 25, 2013
Messages
7,776
You can run commands inside the jail from the NAS by using
/usr/local/bin/iocage exec <jailname> <command> ...

Please check if the path for iocage is correct. I am not at my NAS at the moment. which iocage should do it.
 

nikkon

Contributor
Joined
Dec 16, 2012
Messages
171
thanks
 
Top