How to respawn crond when it dies

I have an intermittent problem where crond dies.

Is there a way to respawn a daemon that dies in Centos?

Ta

7 Replies

You could probably just set up a cron job that restarts it if it isn't running.

I apologize for my previous answer. Been waiting a very long time to use that one.

… but for good reason. Cron is usually solid as a rock, and shouldn't be dying unless there's something seriously bad going on. You probably want to figure out why it crashes and address that.

Another idea might be to write a daemon that periodically checks to ensure cron is running.

BOOM-TISH hoopy :)

Well, where should I start looking to see why it died? cron logs show nothing…..

Any pattern to it? Anything else dying? Hitting the oom-killer or anything like that?

it is a rather boring setup, without enough punishment to OOM.

I have cron executing a php script every 2 minutes and i log the results to a file.

The only thing I can think of is when i logrotate this particular log file.. there may be a collision with the cron daemon if they both want access to the file at the same time.

I have no idea whether cron and logrotate can collide in this siutation.

You could use something like monit to monitor/restart crond. But if something's killing off crond, there's no guarantee it won't kill off the monit daemon as well.

Another option might be using inittab to respawn crond if it dies.

Cron usually doesn't write to log files directly (it uses syslog), and even if something it spawns crashes, the problem will be isolated to that process.

Might be worth checking your distribution's bug tracker, and opening a bug report if it's not a known issue. All software has bugs, and this sounds like one! -rt

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct