Table of Contents
Cron jobs ffp script
Supposing you already know what cron is, here is how you enable cronjobs on your NAS. Below are two ffp scripts, one for enabling the service, and the other for cronjobs.
/ffp/start/crond.sh - The service
#!/ffp/bin/sh # PROVIDE: crond # REQUIRE: LOGIN . /ffp/etc/ffp.subr name="crond" start_cmd="crond_start" stop_cmd="crond_stop" status_cmd="crond_status" crond_start() { cronfile=/var/run/crond.pid #get the pid, if it exists if [ ! -f $cronfile ];then crond -b -L /mnt/HD_a2/logs/cron.log return fi thispid=`cat $cronfile` if [ ! -d /proc/$thispid ];then crond -b -L /mnt/HD_a2/logs/cron.log return else echo "crond is already running" fi } crond_stop() { cronfile=/var/run/crond.pid #get the pid, if it exists if [ ! -f $cronfile ];then echo "crond is not running" return fi thispid=`cat $cronfile` if [ ! -d /proc/$thispid ];then echo "crond is not running" else kill -9 $thispid fi } crond_status() { cronfile=/var/run/crond.pid #get the pid, if it exists if [ ! -f $cronfile ];then echo "crond is not running" return fi thispid=`cat $cronfile` if [ ! -d /proc/$thispid ];then echo "crond is not running" else echo "crond is running normally" fi } run_rc_command "$1"
/ffp/start/cronjobs.sh - Jobs
#!/ffp/bin/sh # PROVIDE: cronjobs # REQUIRE: LOGIN . /ffp/etc/ffp.subr name="cronjobs" start_cmd="cronjobs_start" stop_cmd="cronjobs_stop" status_cmd="cronjobs_status" cronjobs_start() { # Report jobs log to an email address echo "EMAIL=" > /tmp/cronjobs # Job 1 - Example that will download latest set of ffp packages automatically echo "0 0 * * * /ffp/bin/rsync -av inreto.de::dns323/fun-plug/0.5/packages /mnt/HD_a2 > /mnt/HD_a2/rsync_ffp_packages.log" >>/tmp/cronjobs # Import jobs to service crontab /tmp/cronjobs echo "setting the following cron jobs:" cat /tmp/cronjobs rm /tmp/cronjobs } cronjobs_stop(){ echo "" >>/tmp/cronjobs crontab /tmp/cronjobs echo "removing all cron jobs" rm /tmp/cronjobs } cronjobs_status() { echo "status not available" } run_rc_command "$1"