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-03-12 14:38:26

thebatfink
New member
Registered: 2011-03-10
Posts: 4

Edit cron job?

Hi,

I have a cron job setup for rsync. But its initial run looks like its going to take a day or two because of the amount of data. I'm worried that its going to start again tonight at 2am whilst last nights is still running? Is that the case? How can I stop tonights job from starting?

Only stuff I can find by searching is how to write the script to add the cron job.. not to delete or change it..

Thanks
Batfink

Offline

 

#2 2011-03-12 16:52:49

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

Re: Edit cron job?

One way to handle it is to write your script such that it checks to see if it is already running in memory (either directly using 'ps' or code a 'flag' file into the script).  Personally, I use the flag file approach as I can easily see which scripts are active at any time.

To edit a cron job manually, just type 'crontab -e' and then manually modify the jobs. You can comment out the ones you want to skip then remove the comment ('#') later to have it run again.


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

Offline

 

#3 2011-03-12 21:42:00

dhub
Member
Registered: 2011-01-01
Posts: 112

Re: Edit cron job?

Assuming your script name is "mycoolrsyncscript.sh", you can avoid multiple runs using code like this:

SCRIPTNAME="$@"
/bin/ps aux|/bin/grep $SCRIPTNAME|/bin/grep -v grep > /dev/null
RC="$?"
if [ "$RC" = "1" ]; then
    exit
fi

Offline

 

#4 2011-03-12 23:35:08

adambyrtek
Member
Registered: 2010-12-12
Posts: 27

Re: Edit cron job?

There is some useful advice in this thread, but I personally prefer to invoke the initial rsync run interactively. Thanks to that I can notice any errors, and respond to them quickly. If you're afraid that the ssh session could get disconnected, you can always use screen.

Last edited by adambyrtek (2011-03-12 23:55:48)

Offline

 

#5 2011-03-13 00:57:00

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

Re: Edit cron job?

Actually, since it is rsync, the best advice is to copy the files ('cp') first as it is significantly faster then rsync. Once copied, use rsync to keep the copy up to date.


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

Offline

 

#6 2011-03-19 10:09:01

thebatfink
New member
Registered: 2011-03-10
Posts: 4

Re: Edit cron job?

Hi, thanks for the replies. I managed to figure out the -e and edited out the line. I let rsync do the initial copy (which took like 4 days!) because people had been telling me dates and times and user priviledges and stuff would be lost with cp and it confused me. All works nicely now. Its so liberating knowing if a drive fails, alls not lost!

Offline

 

#7 2011-03-20 22:19:02

adambyrtek
Member
Registered: 2010-12-12
Posts: 27

Re: Edit cron job?

The metadata is preserved if you use "cp -a". Anyway, I still prefer to use rsync because it shows the progress and allows me to resume the transfer if necessary.

Offline

 

Board footer

Powered by PunBB
© Copyright 2002–2010 PunBB