DSM-G600, DNS-3xx and NSA-220 Hack Forum

Unfortunately no one can be told what fun_plug is - you have to see it for yourself.

You are not logged in.

Announcement

#1 2011-01-19 22:40:19

electroMilk
Member
Registered: 2011-01-19
Posts: 10

Crond.sh + System Time problem.

Hi guys smile

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:

Code:

#!/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

Code:

#!/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:

Code:

**** 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

 

#2 2011-01-19 23:21:49

Mijzelf
Member / Developer
Registered: 2008-07-05
Posts: 709

Re: Crond.sh + System Time problem.

* /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

 

#3 2011-01-20 09:22:48

fonz
Member / Developer
From: Berlin
Registered: 2007-02-06
Posts: 1716
Website

Re: Crond.sh + System Time problem.

Isn't the firmware running its own crond?

Offline

 

#4 2011-01-20 11:08:18

electroMilk
Member
Registered: 2011-01-19
Posts: 10

Re: Crond.sh + System Time problem.

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

Code:

# 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

 

#5 2011-01-20 12:13:13

FunFiler
Member
Registered: 2010-05-23
Posts: 577

Re: Crond.sh + System Time problem.

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)


3 * (DNS-323 with 2 * 2TB) = 12TB Running FW v1.08 & FFP v0.5
Useful Links: Transmission, Transmission Remote, Automatic

Offline

 

#6 2011-01-20 14:44:16

electroMilk
Member
Registered: 2011-01-19
Posts: 10

Re: Crond.sh + System Time problem.

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:

Code:

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

 

#7 2011-01-20 20:46:27

karlrado
Member
Registered: 2009-12-07
Posts: 229

Re: Crond.sh + System Time problem.

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.


DNS-323 FW 1.07 : 2 1TB WD Caviar Green SATA : fun_plug: utelnet + optware (no ffp)

Offline

 

#8 2011-01-20 23:52:30

electroMilk
Member
Registered: 2011-01-19
Posts: 10

Re: Crond.sh + System Time problem.

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?

Code:

*/15 * * * * ./ffp/bin/php /mnt/HD_a2/newsbin/web/hellavcr/hellavcr.php >> /mnt/HD_a2/logs/hellaVCR.log

Offline

 

#9 2011-01-21 10:18:54

electroMilk
Member
Registered: 2011-01-19
Posts: 10

Re: Crond.sh + System Time problem.

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 smile

Offline

 

Board footer

Powered by PunBB
© Copyright 2002–2010 PunBB