Unfortunately no one can be told what fun_plug is - you have to see it for yourself.
You are not logged in.
I have been beating my head against a wall for a few days and am no closer to an answer now, than I was then. Admittedly, I'm quite the linux newbie, but I've learned a lot in the past couple weeks but none of it is helping me right now.
I have two drives in my DNS-323. My HD_a2 has all my data and I want to set up a cronjob to back that data up nightly to my HD_b2. I followed all the instructions here: http://dns323.kood.org/forum/viewtopic. … 50&p=1. It was pretty straightforward and after a few attempts, I actually got the cronjob to run and back up all my data. However, I haven't been able to get it to run since. When I reboot my 323, I run, crontab -l and I get the following:
59 1 * * * /usr/sbin/daylight& 30 2 * * * /usr/sbin/stime& 32 2 * * * /usr/sbin/rtc -s 30 2 2 * * /usr/sbin/rtc -c 1 15 * * * /mnt/HD_a2/ffp/bin/rsync -av --delete --backup --backup-dir=../backup_rsync_save/2010-09-19 /mnt/HD_a2/* /mnt/HD_b2/rsync_save >> /mnt/HD_a2/ffp/log/rsync.last.log 2>&1
I see my cronjob scheduled and all is well. And then, when the time comes for the job to run, it won't run and if I run crontab -l again, the job will no longer be there and this is what i get:
59 1 * * * /usr/sbin/daylight& 30 2 * * * /usr/sbin/stime& 32 2 * * * /usr/sbin/rtc -s 30 2 2 * * /usr/sbin/rtc -c
I thought it might be a permissions thing, but I'm not sure how that could be the issue. What would cause a scheduled cronjob to just disappear?
A couple other interesting pieces of information, if I reboot the 323, and run crontab -l, I can see it listed, but as soon as I click on the shared drive to access the 323 from my computer, I'll immediately run crontab -l and the cronjob will be gone. The same goes for logging into the 323 via the web interface. As soon as I do that, the cronjob disappears as well. So, it looks like logging into the DND-323 via a browser, accessing the drive via my computer or allowing it the cronjob run will as all delete the cronjob.
I sure would appreciate some help with this.
Last edited by stevelucky (2010-09-20 01:35:12)
Offline
Hi stevelucky,
have a look at the following thread http://dns323.kood.org/forum/t265-littl … ccess.html
cron jobs will get lost following a reboot, thus a script is used to set up the cron jobs once the dns-323 restarts.
I use the so called "time machine" backup in my signature, maybe that would give you better results.
good lucky
Offline
Yeah, maybe the time machine backup is a little more of what I need. One question though, since I've already run the backup using my first cronjob, will I need to back up that data all over again? It's almost 1TB of data so I'd rather not have to run it all over again. Or will it see that the data is already there and just look for changes?
Offline
Actually, this doesn't fix my problem. I set everything up, just as you had outlined. I reboot my 323, and I can see the cronjob, by running crontab -l. As soon as I log in to the 323 interface, the cronjob disappears (I confirm this by running crontab -l, again). Or if I access it via the finder, it disappears as well. Why would accessing the 323 cause the cronjob to disappear?
Offline
I had the same issue. It seems it is a timing issue on boot up.
I inserted a 3 minute delay '/ffp/bin/sleep 3m' into my addcron script and it worked perfectly. May help you too.
Offline
I'll give that a shot. So, where should I put that in the script? Does it matter where it's placed?
So, like this?
#!/bin/sh CRONTXT=/mnt/HD_a2/crontab.txt # start with existing crontab /bin/crontab -l > $CRONTXT # wait 3 minutes before running the script /ffp/bin/sleep 3m # 1. add the Rsync job to execute at 2:05 am 2. Create a logfile (append to any existing log file) 3. Create a backup directory on Vol_B for deleted files # note: use a single > after /mnt/HD_b2 if you want to a create a new log file each night with no append /bin/echo "45 10 * * * /mnt/HD_a2/ffp/bin/rsync -av --delete --backup --backup-dir=../backup_rsync_save/`date +%Y-%m-%d` /mnt/HD_a2/* /mnt/HD_b2/rsync_save >> /mnt/HD_a2/ffp/log/rsync.last.log 2>&1" >> $CRONTXT # install the new crontab /bin/crontab $CRONTXT # clean up /bin/rm $CRONTXT
Last edited by stevelucky (2010-09-20 20:24:34)
Offline
FunFiler wrote:
I had the same issue. It seems it is a timing issue on boot up.
I inserted a 3 minute delay '/ffp/bin/sleep 3m' into my addcron script and it worked perfectly. May help you too.
That did it! Thank you so much.
Offline
No problem, glad it worked. BTW - it doesn't really matter where you put it in the script as long as it is before
# install the new crontab
/bin/crontab $CRONTXT
To cover the unlikely event that something else goes on, I'd suggest moving it above
# start with existing crontab
/bin/crontab -l > $CRONTXT
On another note, I found a way to set this up so that I can edit and rerun the script numerous times to test it out. Without any changes, you will duplicate the new cron entries, which obviously would not be good.
What you can do, is run 'crontab -l' on its own and count the number of default lines (it changes depending on what options / configuraiton you have). Between my 2 NAS units, it is either 5 or 6 (one is Raid 1 and the other is independant drives). Then modify the line that saves the cron entries as follows:
/bin/crontab -l|head -n 5 > $CRONTXT
Change the "5" above to the number of lines. This will strip out any extra entries before appending the new ones allowing you to run the script as many times as required to test different settings etc.
Offline
It is sort of odd that the sleep is needed. I suppose that some other process is running in the background during init that starts in the background. Oh, I see: In /etc/rc.sh there is an invocation of "crond", which would cause the cron daemon to start running, which probably includes loading the default crontab. It may not finish loading the default crontab before calling the user fun_plug.
I've got a pretty long fun_plug script and I modify my crontab at the very end of it, so I think I've been lucky so far, as far as the timing goes. I must be doing enough stuff in my fun_plug to allow crond to finish loading the default crontab before I change it.
Although sleeping is OK, I wonder if a more robust solution is possible. Maybe go into a loop, reading the crontab with "crontab -l" until it returns some output? Then set the new crontab.
Offline
I'm sure you could get really fancy, but personally I only reboot every couple of months so a 3 minute delay is no big deal. Also, my jobs run at night so as long as I reboot in the day it is just fine.
The ability to edit the script and rerun it without rebooting is more important to me and that is why the "head" command helps in my situation more than the sleep.
Last edited by FunFiler (2010-09-21 21:10:11)
Offline
I'm having the same problem as Stevelucky- adding '/ffp/bin/sleep 3m' doesnt seem to be doing the trick
here's my script :
----------------------------------------
#!/bin/sh
# wait 3 minutes before running the script
/ffp/bin/sleep 3m
CRONTXT=/mnt/HD_a2/crontab.txt
# install the new crontab
/bin/crontab $CRONTXT
# start with existing crontab
/bin/crontab -l > $CRONTXT
#add backup specific folders of Volume_1 (/mnt/HD_a2) to Volume_2 (/mnt/HD_b2) at
/bin/echo "15 15 * * * /ffp/bin/rsync -av -delete /mnt/HD_a2/testt /mnt/HD_b2/testt" >> $CRONTEXT
# clean up
/bin/rm $CRONTXT
Offline
Any tips on how to modify crontab so that my rsync task stays??
Offline
#!/bin/sh
# wait 3 minutes before running the script
/ffp/bin/sleep 3m
CRONTXT=/mnt/HD_a2/crontab.txt
# install the new crontab
/bin/crontab $CRONTXT
# start with existing crontab
/bin/crontab -l > $CRONTXT
#add backup specific folders of Volume_1 (/mnt/HD_a2) to Volume_2 (/mnt/HD_b2) at
/bin/echo "15 15 * * * /ffp/bin/rsync -av -delete /mnt/HD_a2/testt /mnt/HD_b2/testt" >> $CRONTXT
/bin/crontab $CRONTXT
# clean up
/bin/rm $CRONTXT
Last edited by bjby (2011-12-13 22:13:09)
Offline
Thanks. Unless i misunderstand your intentions you did a copy/paste of my last script. Am i missing anything else?
Offline
He added a line after the backup line was appended to the crontab file that would reload the modified crontab file.
That being said, I still don't think it is right.
The lines:
# install the new crontab
/bin/crontab $CRONTXT
shouldn't be done before the file $CRONTXT is created. Crontab just reports an error about a missing file and leaves the in-memory crontab alone, so no harm.
How about:
#!/bin/sh
# wait 3 minutes before running the script
/ffp/bin/sleep 3m
CRONTXT=/mnt/HD_a2/crontab.txt
# Write out the original DLink firmware crontab
/bin/crontab -l > $CRONTXT
#add backup specific folders of Volume_1 (/mnt/HD_a2) to Volume_2 (/mnt/HD_b2) at
/bin/echo "15 15 * * * /ffp/bin/rsync -av -delete /mnt/HD_a2/testt /mnt/HD_b2/testt" >> $CRONTXT
# install the new crontab
/bin/crontab $CRONTXT
# clean up
/bin/rm $CRONTXT
Untested....
Offline
Tnx, I'll test it out and let you know.
Offline
Tnx, it survived the reboot- it works. yay!
Offline