Score:0

Crontab not working as expected

kr flag

Dears,

i configured script in crontab to run every 10 minutes and its not working at all. I dont see any entry in configured log path (/var/log/cron)

"*/10 * * * * example_script.sh"

However if i change crontab syntax to following:

"* * * * * example_script.sh"

It executing script every 10 minutes. I see that in configured log path Crond is running, it even has been restarted. No errors in cron log file. example_script.sh is just an example, i have it configured with absolute path. Also it works accordingly with the same crontab configuration but on the other system which serves for the same purpose (just in another network zone)

Why is that happening? Are there any config files allowing to modify crontab syntax itself?

in flag
Do you actually have the quotes in your crontab? And the typo `examlpe`?
Sudoo avatar
kr flag
No, those quotes are only for formating purpose for this site. i have it configured without quotes
Prem avatar
cn flag
When you ask `cron` to execute every 10 minutes , it does not execute. Yet when you ask `cron` to execute every minute , it somehow executes every 10 minutes ! I think you are not interpreting the Execution output correctly. **Append a line with timestamp** to `/tmp/mycronlogger` in your Script & I am sure you will see that it is working Correctly on time. Still , when that is not working , you can then include the timestamp lines to the Post which will help Debug further.
Roman Spiak avatar
it flag
please try to reference your `example_script.sh` with absolute path and make sure that script is executable. Also make sure crond daemon is running on your system.
Sudoo avatar
kr flag
@RomanSpiak - example_script.sh is just as an example, i have it configured with ablosule path. Crond is running on my system, it has even been restarted. It all works accordingly on other linux server which serves for the same purpose just in different network zone.
Sudoo avatar
kr flag
@Prem logging is already configured in rsyslogd to log script execution to /var/log/cron and i literally see that it is being executed every 10 minutes
Score:1
us flag

not all versions of cron support the step extension.

check the crontab(5) man page to see what your version supports.

man 5 crontab

if you can't use */10 you'll have to do it the long way - with a list

0,10,20,30,40,50 * * * * example_script.sh
Sudoo avatar
kr flag
As said in the post, i have 1:1 server which have it configured */10 and it works. It however might have some configured files changed over the time of usage and i rather think it can be some OS related issue
Score:1
kr flag

Root password expired so i changed it to never expire and i must have wait a while to have cron working accordingly

Score:0
sa flag

It is strange that the following is executing it every 10 minutes:

* * * * * example_script.sh

It should run it every minute. Or do you have some sleep in your example_script.sh?

How do you configure the cronjob? Just crontab -e or are you placing it somewhere in /etc/cron.d?

Sudoo avatar
kr flag
Yep, i know thats strange thats why im looking for an answer outside of the documentation. I dont have any sleep configured in script, i did configured it with crontab -e. As already said, same config works on other server
C-nan avatar
sa flag
If it is running every 10 minute, I think somewhere you have `*/10` even though you don't see it. Have you rebooted the machine? Just to be sure that all services are restarted.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.