Cron doesn't start automatically [merged thread]

Questions and mods regarding system management may go here
Forum rules
Please note the disclaimer before modifying your Synology Product.
Ricciolo
Trainee
Trainee
Posts: 16
Joined: Sun Jan 13, 2008 2:29 pm

Cron doesn't start automatically [merged thread]

Postby Ricciolo » Sat Aug 23, 2008 10:48 am

Hi guys,
I have got a problem with Cron. When the NAS boot the daemon doesn't start automatically but if I call /usr/syno/etc.defaults/rc.d/S04crond.sh start manually it works.
Do you know why? Is there any log to see if some errors happen? Is there a file to indicate to start this daemon?
I tried to insert the command into the /etc/rc.local but it seem to ignore my command.

thanks
User avatar
itari
Sharp
Sharp
Posts: 181
Joined: Mon Jun 16, 2008 9:17 am
Location: Germany

Re: Cron doesn't start automatically

Postby itari » Sun Aug 31, 2008 11:06 am

hi Ricciolo,

how do you indicate, that crond is not working? ps?

Sometimes the /etc/crontab does not work, if the field-delimiters are not tabs. Inspect the file with an editor which shows you white space characters.

itari
Ricciolo
Trainee
Trainee
Posts: 16
Joined: Sun Jan 13, 2008 2:29 pm

Re: Cron doesn't start automatically

Postby Ricciolo » Sun Aug 31, 2008 3:36 pm

Sorry, I have checked and, the process crond start (using ps) but it doesn't execute the commands. If I restart the service then it works.
The /etc/crontab file it's ok because if I restart service the commands are executed
User avatar
itari
Sharp
Sharp
Posts: 181
Joined: Mon Jun 16, 2008 9:17 am
Location: Germany

Re: Cron doesn't start automatically

Postby itari » Sun Aug 31, 2008 3:48 pm

Wonder about it, but the same /etc/crontab would sometimes work and sometimes not. Look for TABs in the file. Make a copy of your /etc/crontab and change the shutdown-time in Disk Station Manager. This would rebuild your /etc/crontab. Try this rebuilded file.

You know, that the crond will not use the /etc/crontab directly; crond looks at files in /var/spool/cron/crontabs. Be sure, that the link to your /etc/crontab is possible (look into your /usr/syno/etc/rc.d/S04crond.sh).

If you like an user-friendly interface for your CronJobs, you may have a look at my 3rd-party-apps http://www.synology-forum.de/showthread.html?t=2217

itari
fyllon
I'm New!
I'm New!
Posts: 3
Joined: Fri Feb 27, 2009 12:49 am

Re: Cron doesn't start automatically

Postby fyllon » Fri Feb 27, 2009 12:57 am

Hi guys,

I am having exactly the same problem as described by Ricciolo. Every time I reboot the DS107+, although crond runs, it fails to execute any entry in the crontab file, other than the very first line, which is the ntpd. I then stop and start crond, which on second attempt always succesfully runs all entries in the crontab file.

I have made sure that all my lines are using TABs instead of spaces. I am running FW 2.0-0803. I have changed the NTP setting via the WebGUI to generate a new crontab, which has made no difference.

Is there any way to fix this?

Thanks,

Fyllon
NetUser
I'm New!
I'm New!
Posts: 9
Joined: Sun Nov 02, 2008 3:56 pm

Re: Cron doesn't start automatically

Postby NetUser » Thu Mar 19, 2009 1:40 pm

I have exact same problem.

I found that crontab is run but not correctly. I have a bash script in the job to backup a directory by cp -al. It create a filename with a name suppose to be the backup directory. It is suppose to be @dir.backup directory structure. But I got @dir.backup file instead. I run it without any issue by restart cron job.

Can anyone know this well give us some help?

Thanks in ahead.
milo
Rookie
Rookie
Posts: 35
Joined: Fri Nov 21, 2008 1:08 am

Crond doesn't work

Postby milo » Wed Sep 23, 2009 11:04 am

I think I have read over 100 posts regarding crond not working, most just trail off into oblivion, and just a select few where folks seem to have gotten it working with the main common comment being "use tabs". I have tried every suggestion in these posts and for the life of me cannot get crond to execute even a simple command. As a simple test I added the following to my etc/crontab file:

Code: Select all

15     5    *    *    *    root    ls >> /volume1/SynologyDownload/OneTimeTest.log
*/5    *    *    *    *    root    ls >> /volume1/SynologyDownload/Test.log


I started from scratch and made sure there are tabs between all options. I confirmed even after a re-boot my edited crontab is intact. Nothing happens!! For what it is worth,

Code: Select all

/usr/syno/etc/rc.d/S04crond.sh stop

does NOT kill crond on my DS207. I found this out by

Code: Select all

ps | grep crond

and found multiple crond's running. So now I just manually "kill" it and then restart with

Code: Select all

/usr/syno/etc/rc.d/S04crond.sh start


I am running the kill and start commands as root.

Does anyone have any other ideas?

Thanks!!
DS207 / DSM 2.1-0844 / 1 x Seagate ST31000340AS 1TB
milo
Rookie
Rookie
Posts: 35
Joined: Fri Nov 21, 2008 1:08 am

Re: Crond doesn't work

Postby milo » Thu Sep 24, 2009 10:18 pm

So that my post doesn't end up in oblivion with no solution, I finally got my crond to work. It could have been a number of things but this is what I did.

1 Made absolutely sure I had no spaces, only tabs (I think I found one)
2 As I mentioned above I had to manually kill crond. I found out "killall crond" was effective and easy to type
3 I followed the recommendation in the 3rd post in this thread http://forum.synology.com/enu/viewtopic.php?f=27&t=2707&p=10868&hilit=+cron+reboot#p10868 to keep from losing my edits on reboot.
4 I re-started crond using "/usr/syno/etc/rc.d/S04crond.sh start" after making changes to crontab
5 I did all these things while logged in as root.

Somewhere along the line my scheduled program started executing per my crontab entry.
DS207 / DSM 2.1-0844 / 1 x Seagate ST31000340AS 1TB
milo
Rookie
Rookie
Posts: 35
Joined: Fri Nov 21, 2008 1:08 am

Re: Cron doesn't start automatically

Postby milo » Tue Nov 24, 2009 4:44 pm

This is an old thread but it seems like there was never a solution. I have modified my crontab and all works as expected EXCEPT after a reboot. I have to manually start crond as other have mentioned.

Could someone from Synology comment on how to get crond to start automatically using a user modified crontab? (or anyone who has successfully gotten a custom crontab to work on a reboot).

I even tried putting

Code: Select all

/usr/syno/etc/rc.d/S04crond.sh stop
/usr/syno/etc/rc.d/S04crond.sh start

in the rc.local file, but that did not help. I have added another line in the rc.local file to mount a share from another NAS that executes just fine on reboot so I know that is working.
DS207 / DSM 2.1-0844 / 1 x Seagate ST31000340AS 1TB
jaymonkey
I'm New!
I'm New!
Posts: 8
Joined: Wed Mar 17, 2010 12:10 pm

Cron / CronD not running jobs after a reboot

Postby jaymonkey » Wed Mar 17, 2010 12:44 pm

Howdy All,
Ok I got a DS109, its great, it does everything i want, except start my cronjobs after a reboot. Like many I’ve found that stopping and restarting cron after a reboot makes everything work ok.

/usr/syno/etc/rc.d/S04crond.sh stop
/usr/syno/etc/rc.d/S04crond.sh start

However this is no good. This DS was purchased for one of my customers as a remote mail server. The cronjobs use getmail to gather emails from various remote systems every 5 mins. The end user cannot be expected to ssh into the DS and restart cron after a reboot /power loss ... etc

Please can anyone help with this problem, I’ve read loads of posts about this issue but no one seems to have a definite fix. Many people are suffering with this issue, surely someone, somewhere has a definitive answer?

Other threads:-

http://forum.synology.com/enu/viewtopic.php?f=27&t=9930&p=78651&hilit=crond+start#p78651
http://forum.synology.com/enu/viewtopic.php?f=39&t=17673&p=73752&hilit=crond+start#p73752

In all cases after a reboot the cronjobs are not active so i need to stop and start cron in order for it to start processing my cronjobs, its driving me nuts, i cant believe that something so simple can let down what is otherwise a great little server.

Cheers
Jay
jaymonkey
I'm New!
I'm New!
Posts: 8
Joined: Wed Mar 17, 2010 12:10 pm

Cron not running cronjobs after a reboot

Postby jaymonkey » Thu Mar 18, 2010 1:06 pm

Hi,

Forum Admin,

I Created a new topic on the subject of Cron not running cronjobs after a reboot but you have merged with a thread which was last posted to over two years ago ???? -

http://forum.synology.com/enu/viewtopic.php?f=39&t=17673&p=91304

Comon, the only people who are going to find it there are people who have the same problem and have searched the archive, so its never going to get solved.....think about it.
Can you please post it as a new thread so that maybe someone who has a solution will see it ?

Cheers - Jay
Admin
Site Admin
Site Admin
Posts: 147
Joined: Fri Oct 13, 2006 12:55 am

Re: Cron not running cronjobs after a reboot

Postby Admin » Thu Mar 18, 2010 9:43 pm

When you reply to a post, the thread automatically moves to the top of the room -therefore people will see that a new post was made.

Have a good day.
jaymonkey
I'm New!
I'm New!
Posts: 8
Joined: Wed Mar 17, 2010 12:10 pm

Alternative to Cron

Postby jaymonkey » Mon Mar 22, 2010 1:29 pm

Hi,

Does anyone know of an alternative to cron ?

I want to run a python script every 5 mins, but i need it to start automatically after a reboot. Which is a problem for DS boxes as posted here:-

http://forum.synology.com/enu/viewtopic.php?f=39&t=17673

Has anybody tried to use the cron included in the current ipkg list ?, does this run independently of the one included on the DS ?, are there any issues running to cron demons on a DS ?

Cheers
Jay
arberg
I'm New!
I'm New!
Posts: 5
Joined: Sun Sep 21, 2008 1:53 pm

Re: Cron doesn't start automatically [merged thread]

Postby arberg » Thu Jul 15, 2010 10:18 am

I have been through all the same problems as mentioned in this (and other Synology-forum threads), when trying to get my cron jobs to work on synology. I have finally succeded in getting my jobs to run, even after reboot (which is what really matters to me).

On synology the default installed crond does not work properly with user-added jobs. So I installed the real cron from ipkg:

Code: Select all

  ipkp install cron

The cron is placed in /opt and uses /opt/etc/crontab.
See http://www.nslu2-linux.org/wiki/HowTo/DebugCrontabProblems for information on debugging this cron, and further details on it.
See http://forum.synology.com/wiki/index.php/How_to_Install_Bootstrap for installing ipkg on your Synology diskstation.

The new cron package comes with a cron-command (the running daemon) and crontab (for editing/listing user cron-jobs). The new cron and crontab lie in /opt/bin and the crontab file used by the new cron lies is /opt/etc/crontab.
The crontab program didn't work for me (see below for my problems).

What did work was editing /opt/etc/crontab directly. I just have to restart the cron process after editing the crontab file using eg.

Code: Select all

    killall cron
    cron

or by rebooting the diskstation

Code: Select all

    reboot


My /opt/etc/crontab looks like this (i did not edit the first four lines, I just added the last three lines).

Code: Select all

SHELL=/bin/sh
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/opt/sbin:/opt/bin
MAILTO=""
HOME=/
# ---------- ---------- Default is Empty ---------- ---------- #
#minute hour    mday    month   wday    who     command
10   7   *   *   *   svnreader   /volume2/svnBackup/doAndroidFull.sh
0   *   *   *   *   svnreader   /volume2/svnBackup/doAndroidIncrAll.sh


Strangely enough, the crontab seemed to work for me even though I had a version using spaces in stead of tabs, but its probably best to use tabs only.

My issues with crontab program:
Editing the user-specific crontabs using 'crontab -e -u username' as root didn't work for me, the cron-jobs never get executed. The the error-message listed when I edit the files might have something to do with my problem

Code: Select all

root@/opt/etc> crontab -l
# DO NOT EDIT THIS FILE - edit the master and reinstall.
# (/tmp/crontab.XXXXXTVyhL installed on Wed Jul 14 21:50:35 2010)
# (Cron version V5.0 -- $Id: crontab.c,v 1.12 2004/01/23 18:56:42 vixie Exp $)

I don't think this message was there when I installed the cron the first time, so maybe using crontab program works for you.
jabraham
Trainee
Trainee
Posts: 11
Joined: Sat Sep 01, 2007 7:09 am

Re: Cron doesn't start automatically [merged thread]

Postby jabraham » Wed Aug 18, 2010 4:27 am

Thanks for the update, arberg. I've never been able to get cron to reload my crontab, no matter how many spaces and tabs there are or are not in the file. Sounds like I should try the other cron.

I've always had to restart cron after every power failure in the house, which is not a big disaster for me but it's very annoying nonetheless.

--
John

Return to “System Managment Mods”

Who is online

Users browsing this forum: cnyc and 4 guests