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.

My cronjob is being repeated every 15 minutes and I don't have any idea why.

Here is the crontab file with real commands replaced:

# m h  dom mon dow   command
# Comment
0 9 * * * command arg1
0 14 * * * command arg1
0 19 * * * command arg1
0 1 * * * command arg1
#0 19 * * * command arg1
#0 22 * * * command arg1

I modified crontab and restarted the server. Everything started as expected. But it kept repeating the command every 15 min. My command is a sh script which uses wget to start web service.

I have a feeling that crontab repeats failed command after 15 minutes (wget fails most of the time because web service requires more than 1 minute to execute). Am I right? And how can this be fixed?

share|improve this question
add comment

3 Answers

I'm lazy, so only two quick answers.

The first one is to look under /etc/cron* to see if there are some interesting thing that can answer your question.

The second one is to look at ps aux to see if there are some process that you don't know and maybe is there to launch your script every 15 minutes.

Then for free a third one, you can modify your script to tell (log) from who it is launched, maybe adding at the begin something like ps aux | grep $PPID > /tmp/your_script_parent_process.log.

I was forgiving. There could be also another answer, maybe the command is executed by means of the crontab of another user.

Andrea

share|improve this answer
add comment

cron does not reattempt jobs. It simply runs commands on a schedule. It does not necessarily care if they succeed or fail. cron also does not impose any sort of timeouts.

You may want to check your syslog and /var/log/cron (at least that's where it is on RedHat-style systems).

Also, if the user owning the crontab is not receiving email messages regarding the output of the wget command, insert a MAILTO=you@your.email.address in order to get a better picture of what is happening when the command is being executed.

See:

man 5 crontab

...for more details about some of the other settings that can be configured for the user's crontab.


From the WGET man Page

When interacting with the network, Wget can check for timeout and abort the operation if it takes too long. This prevents anomalies like hanging reads and infinite connects. The only timeout enabled by default is a 900-second read timeout. Setting a timeout to 0 disables it altogether. Unless you know what you are doing, it is best not to change the default timeout settings.

share|improve this answer
add comment

I found that by default wget repeats request when it fails. Adding "-t 1" or "--times=1" solved the problem

share|improve this answer
add comment

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.