Unfortunately no one can be told what fun_plug is - you have to see it for yourself.
You are not logged in.
Hi guys
Almost got everything running the way I want it on my new DNS-323.
Got Transmission, NZBget, HellaVCR and Firefly running on it, all without problems.
However, I can't seem to get it to run cron tasks.
When calling a "sh crond.sh status" command, I get "crond is running normally".
Another (new) issue is a problem with the system time on the DNS-323 - you can see a picture of what I mean here.
Any ideas?
crond.sh:
#!/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"
cronjobs.sh
#!/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 at midnight 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 # Job 2 - add the HellaVCR job to execute every 15 minutes - create a log file. */15 * * * * php /mnt/HD_a2/newsbin/web/hellavcr/hellavcr.php >>/mnt/HD_a2/ # 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"
ffp.log:
**** fun_plug script for DNS-323 (2008-08-11 tp@fonz.de) **** Tue Jan 18 13:43:26 GMT 2011 ln -snf /mnt/HD_a2/ffp /ffp * Running /ffp/etc/fun_plug.init ... * Running /ffp/etc/rc ... * /ffp/start/syslogd.sh ... Starting /ffp/sbin/syslogd Starting /ffp/sbin/klogd -c 3 * /ffp/start/SERVERS.sh ... * /ffp/start/portmap.sh ... Starting /ffp/sbin/rpc.portmap * /ffp/start/unfsd.sh ... Linking /etc/exports ... WARNING: rpc.portmap: Already running Starting /ffp/sbin/unfsd -e /ffp/etc/exports * /ffp/start/transmission.sh ... Starting transmission-daemon * /ffp/start/nfsd.sh ... WARNING: rpc.portmap: Already running Starting /ffp/sbin/rpc.statd exportfs: /etc/exports [1]: Neither 'subtree_check' or 'no_subtree_check' specified for export "192.168.1.0/24:/mnt/HD_a2". Assuming default behaviour ('no_subtree_check'). NOTE: this default has changed since nfs-utils version 1.0.x exportfs: /etc/exports [2]: Neither 'subtree_check' or 'no_subtree_check' specified for export "192.168.1.0/24:/mnt/HD_a4". Assuming default behaviour ('no_subtree_check'). NOTE: this default has changed since nfs-utils version 1.0.x exportfs: /etc/exports [3]: Neither 'subtree_check' or 'no_subtree_check' specified for export "192.168.1.0/24:/mnt/HD_b2". Assuming default behaviour ('no_subtree_check'). NOTE: this default has changed since nfs-utils version 1.0.x exportfs: /etc/exports [4]: Neither 'subtree_check' or 'no_subtree_check' specified for export "192.168.1.0/24:/mnt/HD_b4". Assuming default behaviour ('no_subtree_check'). NOTE: this default has changed since nfs-utils version 1.0.x exportfs: /etc/exports [5]: Neither 'subtree_check' or 'no_subtree_check' specified for export "192.168.1.0/24:/mnt/web_page". Assuming default behaviour ('no_subtree_check'). NOTE: this default has changed since nfs-utils version 1.0.x Starting /ffp/sbin/rpc.nfsd 8 Starting /ffp/sbin/rpc.mountd * /ffp/start/ntpd.sh ... Starting /ffp/bin/ntpd -g -f /ffp/etc/ntp.drift * /ffp/start/LOGIN.sh ... * /ffp/start/telnetd.sh ... Starting /ffp/sbin/telnetd -l /ffp/bin/sh * /ffp/start/kickwebs.sh ... Kicking webs ... * /ffp/start/startweb.sh ... Starting /ffp/sbin/lighttpd -f /mnt/HD_a2/newsbin/conf/lighttpd.conf * /ffp/start/startnzbget.sh ... Starting /mnt/HD_a2/newsbin/bin/nzbget -D -c /mnt/HD_a2/newsbin/conf/nzbget.conf * /ffp/start/sshd.sh ... Starting /ffp/sbin/sshd * /ffp/start/rsyncd.sh ... /ffp/etc/rsyncd.conf: Required file not found or not readable * /ffp/start/mysqld.sh ... Starting mysqld_safe * /ffp/start/mt-daapd.sh ... Starting /ffp/sbin/mt-daapd * /ffp/start/mediatomb.sh ... Starting /ffp/bin/mediatomb -d --interface egiga0 --home /ffp/var --cfgdir mediatomb --add /mnt/HD_a2/home/media 2011-01-18 13:43:34 INFO: Loading configuration from: /ffp/var/mediatomb/config.xml 2011-01-18 13:43:34 INFO: Checking configuration... 2011-01-18 13:43:35 INFO: Setting filesystem import charset to ASCII 2011-01-18 13:43:35 INFO: Setting metadata import charset to ASCII 2011-01-18 13:43:35 INFO: Setting playlist charset to ASCII 2011-01-18 13:43:35 INFO: Configuration check succeeded. * /ffp/start/lighttpd.sh ... WARNING: lighttpd: Already running * /ffp/start/inetd.sh ... /ffp/etc/inetd.conf: Required file not found or not readable * /ffp/start/cronjobs.sh inactive * /ffp/start/crond.sh inactive * /ffp/start/avahi.sh ... Starting /ffp/sbin/avahi-daemon -D -s Process 2413 died: No such process; trying to remove PID file. (/ffp/var/run/avahi-daemon//pid) * /ffp/start/afpd.sh ... /ffp/start/afpd.sh: line 1: OVIDE:: not found * OK $Shutting down SMB services: $Shutting down NMB services: $Starting SMB services: $Starting NMB services:
Offline
* /ffp/start/cronjobs.sh inactive
* /ffp/start/crond.sh inactive
Your scripts are not executable.
When calling a "sh crond.sh status" command, I get "crond is running normally".
This only means that there is a file /var/run/crond.pid, which contains a pid which is actually in use. But not necessarily by cron.
Offline
Thanks Mizjelf - I'm still pretty new to all this.
@Fonz: I've now tried to chmod a-x the crond.sh and cronjobs.sh files I created in the /ffp/start/ directory, and instead done the following:
# crontab -e
and added
# Job 2 - add the HellaVCR job to execute every 15 minutes - create a log file. */15 * * * * php /mnt/HD_a2/newsbin/web/hellavcr/hellavcr.php >>/mnt/HD_a2/logs/hellaVCR.log
But after rebooting the DNS-323, that entry in my crontab is gone.
It's pretty obvious that I'm doing things the wrong way. Any tips or tricks? Or is there a guide in the wiki that I missed?
Thanks!
Offline
On bootup, you need to run a script to add any custom cron jobs as it goes back to the default. There are examples on the wiki on how to do that.
For you time issues, you can remove the rtc and date/time functions installed by default and switch to ntpd. At the same time, you can insert the proper TZ setting to handle Day Light Savings time if appropriate for your location.
Last edited by FunFiler (2011-01-20 12:15:55)
Offline
Reinstalled the ntpd service; that seemed to fix the time issue.
Followed this guide to get the cronjob service to work.
Running crontab -l reveals this:
59 1 * * * /usr/sbin/daylight& 30 2 * * * /usr/sbin/stime& */60 * * * * /usr/sbin/getdhcp& 32 2 * * * /usr/sbin/rtc -s 30 2 2 * * /usr/sbin/rtc -c */15 * * * * php /mnt/HD_a2/newsbin/web/hellavcr/hellavcr.php >> /mnt/HD_a2/logs/hellaVCR.log
However, my hellavcr.php script still doesn't seem to run. Any thoughts? The hellaVCR.log file isn't even created, so I'm confident it hasn't run yet.
Offline
Probably a PATH problem.
crontab uses the "firmware" shell to spawn cron jobs. Its PATH is usually set to
/usr/bin:/bin:/usr/sbin:/sbin
and so is not finding your php program.
You might try specifying the full path to php, which is a simple solution and the one employed by the other crontab entries in your crontab.
If specifying the full path to the executable is not enough, you can write a wrapper script that sets up the environment the way you want it, including setting PATH, and then starts your executable. Then launch the script from crontab. This is what I do in this situation.
Some versions of cron allow you to set env vars in the crontab file or by some other method. I don't know the details for this approach or what works and does not work on the 323.
Offline
Thanks karlrado
Do you know what the full path to php is? Digging around the php-5.2.17-2 package makes me think that it's "./ffp/bin/php"
Would I call it like this?
*/15 * * * * ./ffp/bin/php /mnt/HD_a2/newsbin/web/hellavcr/hellavcr.php >> /mnt/HD_a2/logs/hellaVCR.log
Offline
It works now.
Here's my editcron.sh entry:
/bin/echo "*/15 * * * * /ffp/bin/php /mnt/HD_a2/newsbin/web/hellavcr/hellavcr.php > /mnt/HD_a2/logs/hellaVCR.log" >> $CRONTXT
Thank you for the help
Offline