Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Note: I've viewed cron: can’t lock /var/run/crond.pid, otherpid may be 3759 but I believe my question is different (but with the same resulting problem.)

I'm very new to cron. I setup a script to run a python script every minute to test that everything was working. I did use crontab to accomplish this. It worked great, so I wanted to switch it to run every 4 hour.

I changed my * * * * * {...} to * */4 * * * {...} but the job is continues to run every minute. It's been like this for the last hour or so.

When I attempt to run cron restart (thinking that would solve the problem), I receive the following error message:

cron: can't lock /var/run/crond.pid, otherpid may be 2311: Resource temporarily unavailable

Is my cron syntax wrong? And why might I not be able to restart cron?

share|improve this question

2 Answers 2

up vote 7 down vote accepted

Your syntax should be

0 */4 * * * <command>

A * in the minute field causes it to run every minute, as you're experiencing. A zero will cause it to run at 0 minutes past the hour, every 4 hours.

Not sure why you can't restart cron; perhaps your cron job is DoS'ing your machine.

share|improve this answer
    
Thank you. This seems to fix my every-minute issue... Still getting the error when trying to restart but for now that doesn't matter. :-) Thanks again, –  Frank V Apr 21 '10 at 22:17

Do you literally mean you typed "cron restart" to restart cron? You should probably be using the init script instead: /etc/init.d/cron restart. I suspect you're seeing the output of the cron server trying to start (i.e. ignoring the "restart" argument).

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.