Unfortunately no one can be told what fun_plug is - you have to see it for yourself.
You are not logged in.
Hey Guys,
I'm trying to setup a cron job on my 323 to run a script. The reason why i want to use a script is so that i only have to change the script and not have to worry about reloading the cron file and editing it all the time.
When i run the script which is called nightly-run it works, but when i try to put it as a cron service it doesn't work. The nightly-run is set to full permissions (777). Does anybody have any ideas i can try????
Here is my output of crontab -l
32 2 * * * /usr/sbin/rtc -s
30 2 2 * * /usr/sbin/rtc -c
59 1 * * * /usr/sbin/daylight &
5 13 * * * /mnt/HD_a2/nightly-run &
Here is the script in nightly-run
#!/bin/sh
rsync -arptv --delete /mnt/HD_a2/Live/ /mnt/HD_b2/Backup/Live/ > /mnt/HD_a2/rsync.Live.log
rsync -arptv --delete /mnt/HD_a2/Backup/ /mnt/HD_b2/Backup/Backup/ > /mnt/HD_a2/rsync.Backup.log
Here is what my editcron.sh looks like:
#!/bin/sh
CRONTXT=/mnt/HD_a2/crontab.txt
# Start with existing crontab
/bin/crontab -l > $CRONTXT
# Runs daily 1:05pm -
/bin/echo "5 13 * * * /mnt/HD_a2/nightly-run &" >> $CRONTXT
# install the new crontab
/bin/crontab $CRONTXT
# Clean up the mess
/bin/rm $CRONTXT
Thanks,
Savva
Offline
Try using the full path to the rsync executable, something like:
/ffp/bin/rsync
in the nightly-run script.
Offline
Hey Mig,
I tried that out, but it didnt work ![]()
Any other suggestions....i've been trying to get this to work for so long and i cant figure out what i'm doing wrong!
Offline
How about creating a log file for the 'nightly-run' cron job, like this:
In the editcron.sh
/bin/echo "5 13 * * * /mnt/HD_a2/nightly-run > /mnt/HD_a2/nightly_run.log &" >> $CRONTXT
output of crontab -l should be:
32 2 * * * /usr/sbin/rtc -s
30 2 2 * * /usr/sbin/rtc -c
59 1 * * * /usr/sbin/daylight &
5 13 * * * /mnt/HD_a2/nightly-run > /mnt/HD_a2/nightly_run.log &
Offline
OK it looks like my crontab is not running....at the very least the file nightly_run.log should of been created.
Here is what my crontab looks like:
root@NAS:/mnt/HD_a2# crontab -l
32 2 * * * /usr/sbin/rtc -s
30 2 2 * * /usr/sbin/rtc -c
59 1 * * * /usr/sbin/daylight &
45 14 * * * /mnt/HD_a2/nightly-run > /mnt/HD_a2/nightly-run.log &
here is the output of the date command as well:
Sat Apr 4 14:50:30 DST 2009
note: reloaded the changes at 2:40 so i gave it 5 mins to run.
This is what a cat of my ffp.log file looks like
**** fun_plug script for DNS-323 (2008-08-11 tp@fonz.de) ****
Sat Apr 4 13:25:57 GMT 2009
ln -snf /mnt/HD_a2/ffp /ffp
* Running /ffp/etc/fun_plug.init ...
* Running /ffp/etc/rc ...
* /ffp/start/syslogd.sh inactive
* /ffp/start/SERVERS.sh inactive
* /ffp/start/portmap.sh inactive
* /ffp/start/unfsd.sh inactive
* /ffp/start/nfsd.sh inactive
* /ffp/start/ntpd.sh inactive
* /ffp/start/smartd.sh inactive
* /ffp/start/LOGIN.sh inactive
* /ffp/start/telnetd.sh inactive
* /ffp/start/sshd.sh ...
Starting /ffp/sbin/sshd
* /ffp/start/rsyncd.sh inactive
* /ffp/start/mediatomb.sh inactive
* /ffp/start/kickwebs.sh inactive
* /ffp/start/lighttpd.sh inactive
* /ffp/start/inetd.sh inactive
* /ffp/start/editcron.sh ...
* OK
It looks like my editcrong is not running
Here is an output of my edit cron.sh file
#!/bin/sh
CRONTXT=/mnt/HD_a2/crontab.txt
# Start with existing crontab
/bin/crontab -l > $CRONTXT
# Runs daily 2:05am -
/bin/echo "35 14 * * * /mnt/HD_a2/nightly-run > /mnt/HD_a2/nightly-run.log &" >> $CRONTXT
# install the new crontab
/bin/crontab $CRONTXT
# Clean up the mess
/bin/rm $CRONTXT
Permission on this file is
-rwxr-xr-x 1 root root 300 Apr 4 14:24 editcron.sh
Offline
O.K. I'm a bit confused with your last post..., you state "It looks like my editcrong is not running"
but the ffp.log has an entry "* /ffp/start/editcron.sh ..."
First, make sure your DNS-323 clock agrees with your wall clock.
that could really mess up any debugging of cron tasks.
Next, add some debug print statements to editcron.sh to verify editcron.sh
is executing correctly. These print statements will appear in ffp.log.
to the beginning of editcron.sh, add:
echo -n "Starting $0 at "
date
and to the end of editcron.sh, add:
echo "Changed crontab to:"
/bin/crontab -l
the new editcron.sh (with debug print statements) should look like this
#!/bin/sh # Debug print statements echo -n "Starting $0 at " date CRONTXT=/mnt/HD_a2/crontab.txt # Start with existing crontab /bin/crontab -l > $CRONTXT # Runs daily 2:05am - /bin/echo "35 14 * * * /mnt/HD_a2/nightly-run > /mnt/HD_a2/nightly-run.log &" >> $CRONTXT # install the new crontab /bin/crontab $CRONTXT # Clean up the mess /bin/rm $CRONTXT # Debug print statements echo "Changes crontab to:" /bin/crontab -l
Then restart your DNS-323 and look at the output of ffp.log, if you see the new debug print statements
then you know the editcron.sh script is executing correctly.
If editcron.sh is executing correctly, then you have to figure out why the nightly-run.log is not being created.
Last edited by mig (2009-04-05 11:24:56)
Offline
Well good news i got it working
.... so here's what my scripts look like
Future expansion i'm going to create is emailing log files ![]()
---------------------------------------------
Editcron.sh
#!/bin/sh
CRONTXT=/mnt/HD_a2/crontab.txt
# Start with existing crontab
/bin/crontab -l > $CRONTXT
# Runs daily 2:05am -
/bin/echo "45 20 * * * /mnt/HD_a2/nightly-run > /mnt/HD_a2/nightly-run.log 2>&1" >> $CRONTXT
# install the new crontab
/bin/crontab $CRONTXT
# Clean up the mess
/bin/rm $CRONTXT
----------------------------------------
Nightly-run
#!/bin/sh
/mnt/HD_a2/ffp/bin/rsync -arptv --delete /mnt/HD_a2/Live/ /mnt/HD_b2/Backup/Live/ > /mnt/HD_a2/rsync.Live.log
/mnt/HD_a2/ffp/bin/rsync -arptv --delete /mnt/HD_a2/Backup/ /mnt/HD_b2/Backup/Backup/ > /mnt/HD_a2/rsync.Backup.log
Offline
So, the problem turned out to be not using the full path to the rsync command in
the nightly-run.sh?
Last edited by mig (2009-04-06 22:00:32)
Offline
Either that or adding in the 2>&1 in the editcron.sh file
I changed both thoes options at the same time so i'm not sure which one fixed it. I was happy it worked i didnt care to try and see which one it was lol .... I Will try in a day or two and let everybody know which one it was
Thanks for the help, it was appreciated
Offline