SOLVED Crontab in jail not persistent

revengineer

Contributor
Joined
Oct 27, 2019
Messages
193
Hello,
I am trying to configure a crontab in a jail. This seems to work fine and is persistent as I take the jail down and back up. However, if I reboot the freenas server, the crontab I created in the jail seems to get deleted. Please let me know what I am missing. I am still new to freenas so forgive my ignorance.

Thank you.
 

Patrick M. Hausen

Hall of Famer
Joined
Nov 25, 2013
Messages
7,776
How precisely did you configure the crontab? Did you use the crontab command like e.g. so?

Code:
root@nextcloud:~ # crontab -u www -l
*/15 * * * * /usr/local/bin/php -f /usr/local/www/nextcloud/cron.php

Kind regards
Patrick
 

revengineer

Contributor
Joined
Oct 27, 2019
Messages
193
Thanks for your response, Patrick. I log into the jail with putty using a user defined in freenas (not root). Then I do "crontab -e" to edit the crontab just as I would under any Linux system. I need to start a command at boot so I use "@Reboot path_to_prog/prog". The crontab looks fine when showing with "crontab -l". Also, if I take down the jail and then back up the program executes and the crontab is still there. But the I reboot the freenas server, and the crontab is all gone.
 

Patrick M. Hausen

Hall of Famer
Joined
Nov 25, 2013
Messages
7,776
If you defined the user in FreeNAS you did not log in to the jail but into the FreeNAS system itself. And changes made on the command line instead of the UI are not persistent. You need to use the UI to add a cron job to FreeNAS or make sure you log into the jail proper.

Like:

Code:
ssh <your-user@freenas>
sudo su -
iocage console <jail>
crontab -u <user> -e


I have ssh enabled in all my jails so I can login directly.

HTH,
Patrick
 

revengineer

Contributor
Joined
Oct 27, 2019
Messages
193
Maybe this is where my mistake is. I ssh'ed to the IP address associated with the jail and assumed that would connect me to the jail.

What did you do to ssh into the jail directly?
 

revengineer

Contributor
Joined
Oct 27, 2019
Messages
193
I found these instructions these instructions and steps 3-8 enabled ssh to the jail.
 

revengineer

Contributor
Joined
Oct 27, 2019
Messages
193
With your pointers, I have the crontab now working and it is persistent. The confusing resulted from the following: When ssh access is not enabled on the jail, ssh to the jail ip address will result in login to the FreeNAS server where crontab is not persistent.

Thank you for your help!
 

Patrick M. Hausen

Hall of Famer
Joined
Nov 25, 2013
Messages
7,776
Not if you use VNET jails which you should. The old "shared host IP" jails are legacy, IMHO.

Glad it is working now.
Patrick

P.S. Please add the "SOLVED" tag to the thread title.
 

revengineer

Contributor
Joined
Oct 27, 2019
Messages
193
I cannot find how to added the "SOLVED" tag to the title.
 

Patrick M. Hausen

Hall of Famer
Joined
Nov 25, 2013
Messages
7,776
Top right menu ...

Bildschirmfoto 2019-12-29 um 19.42.41.png

Bildschirmfoto 2019-12-29 um 19.43.07.png
 

revengineer

Contributor
Joined
Oct 27, 2019
Messages
193
Got it thanks.
 
Top