Setting up Crontab

Questions and mods regarding system management may go here
Forum rules
Please note the disclaimer before modifying your Synology Product.
jonnyzach
Trainee
Trainee
Posts: 10
Joined: Thu Jan 20, 2011 9:44 am

Setting up Crontab

Postby jonnyzach » Thu Jan 20, 2011 9:52 am

I have literally spent hours trying to figure this out on my own. I am, by no means, proficient with Linux or Unix, but have had exposure to it and using the command line to do things.

That said, I am trying to setup a cron job to do a scrub and repair on the RAID array to try to detect and recover from any UREs that may arise.

When I do do vi /etc/crontab I get this:
#minute hour mday month wday who command
05 12 * * 6 root echo repair > /sys/block/md2/md/sync_action

When I do either a /etc/crontab -e or /etc/crontab -l I receive the following error
"/etc/crontab: line 2: 05: not found"

I've tried to google to find out what I did wrong but every site I read indicates I've set this up correctly. I even broke out my old O'Reilly System Administration book from college and everything looks okay as far as I can tell. I did kill the crond process and restarted it just in case that had anything to do with it.

Thanks to anyone who can help me through this. I appreciate the help for a noob like me.
User avatar
maxxfi
Compiler
Compiler
Posts: 6794
Joined: Sun Dec 27, 2009 12:13 pm
Location: Espoo, Finland

Re: Setting up Crontab

Postby maxxfi » Thu Jan 20, 2011 11:22 am

Syntax looks ok.
I would suggest that you try first with something simpler, e.g. try a simple echo:
05 12 * * 6 root echo
If that works ok, then add elements to your command until command is complete
or hit a problem.

EDIT: now I see what's the problem: when you type "/etc/crontab -l"
you are using the textfile you just edited as a command, whose parameter is "-l"
As you get "05: not found" as error, it means that it execute the text file as it would be a script
and after the # line which is skipped as comment, the first 'command' in the next line is 05 :D

Solution is that on Synology there is no real command to edit (-e) or read (-l) the crontab,
you have just that the time comes and see if it gets executed.
DS-106j > DS-210j > DS-411
jonnyzach
Trainee
Trainee
Posts: 10
Joined: Thu Jan 20, 2011 9:44 am

Re: Setting up Crontab

Postby jonnyzach » Wed Jan 26, 2011 5:40 am

I tried that and it didn't seem to work. Do I need to restart the crond daemon process to get it to recognize the changes in the /etc/crontab file? If I run the command itself it does actually run the md2_resync and md2_raid5 processes. It's going to take a loooong time to check all 8TB of disk space. Another stupid question is if I have to add the same entry to the /etc.defaults/crontab file. I'm not sure if the defaults version overwrites the regular /etc file upon reboot. In a standard UNIX environment it doesn't, but this isn't UNIX.

** Note to self: run this while I'm sleeping :wink:
User avatar
HarryPotter
Honorary Moderator
Honorary Moderator
Posts: 18682
Joined: Mon Oct 23, 2006 12:48 pm
Location: Switzerland

Re: Setting up Crontab

Postby HarryPotter » Wed Jan 26, 2011 12:50 pm

jonnyzach wrote:Do I need to restart the crond daemon process to get it to recognize the changes in the /etc/crontab file?

Yes!
/usr/syno/etc/rc.d/S04crond.sh stop
/usr/syno/etc/rc.d/S04crond.sh start
*Please do not Private Message me for support questions; leave it on the forum so all members can learn. Thanks!*

DS718+ / DSM 6.1.3-15152-7 / ST4000VN000-2AH166 / 16 GB RAM
DS713+ / DSM 6.1.3-15152-7 / HD501LJ + HD502IJ (RAID0)
DS415+ / DSM 6.1.3-15152-7

2 Squeezebox 3 + Boom

APC Smart UPS SUA750i
jonnyzach
Trainee
Trainee
Posts: 10
Joined: Thu Jan 20, 2011 9:44 am

Re: Setting up Crontab

Postby jonnyzach » Fri Jan 28, 2011 4:13 am

Thank you for the help. I've gone ahead and done that. I'll check in on it at the next scheduled time to see if it started successfully.
jonnyzach
Trainee
Trainee
Posts: 10
Joined: Thu Jan 20, 2011 9:44 am

Re: Setting up Crontab

Postby jonnyzach » Sun Jan 30, 2011 8:49 pm

That did the trick. It ran yesterday and completed successfully as well as sending me an administrative alert that all was well. Thanks so much for your help and guidance. :D

Return to “System Managment Mods”

Who is online

Users browsing this forum: No registered users and 1 guest