Custom CRON Job

Prev Next

FMADIO System uses a default cronjob that is located as below

/etc/crontab.root

Direct edits to this file will be lost every reboot, as the directory is on the RAMDisk and not persistant.

This can be customized and made persistent across reboots, for anything such as scheduled weekly reboots. By creating the cronjob file as bellow.

cp /etc/crontab.root /opt/fmadio/etc/

This puts the crontab.root file into persistent storage at

/opt/fmadio/etc/

Allowing custom cronjobs to run on the system.

Scheduled Reboot

One example of this is to schedule a system reboot every Sunday night. To do this please see the below example.

fmadio@fmadio20v2-149:~$ cat /opt/fmadio/etc/crontab.root
* * * * * /opt/fmadio/bin/watchdog.lua --nocal >> /mnt/store0/log/watchdog.log
59 23 * * 0 /sbin/reboot
fmadio@fmadio20v2-149:~$

Adding in the last line in the cronjob will schedule the reboot at midnight every Sunday.

NOTE: a reboot or reloading of the crontab file is required for the above to become active

To reload an updated crontab file as follows

sudo crontab /opt/fmadio/etc/crontab.root

Then confirm the update by listing the current cronjobs

 sudo crontab -l

Example output below

fmadio@fmadio200v4-636:~$ sudo crontab -l
* * * * * /opt/fmadio/bin/watchdog.lua --nocal >> /mnt/store0/log/watchdog.log
59 23 * * 0 /sbin/reboot
fmadio@fmadio200v4-636:~$