Hello all,
here is my problem: I have a cronjob that does not execute when scheduling. I went to a couple of trouble shooting action:
1-) grep cron Result:1463 so cron deamon is running
2-)crontab -l Result below:
patrick@patrick-pc ~ $ crontab -l
# Minute Hour Day of Month Month Day of Week Command
# (0-59) (0-23) (1-31) (1-12 or Jan-Dec) (0-6 or Sun-Sat)
MAILTO="****.****.****@gmail.com"
54 7 * * 0,6 /home/patrick/Scripts/script01
55 7 * * 0,6 /home/patrick/Scripts/script02
56 7 * * 0,6 /home/patrick/Scripts/script03
#
3-) Notice the empty remark at the end, I read somewhere that it takes an empty line at the end.
So my questions are: What am I doing wrong ? and Where in the logs can I see if cron returns an error ?
Thanks all
CRON does not execute
Forum rules
LMDE 2 has reached end of support as of 1-1-2019
LMDE 2 has reached end of support as of 1-1-2019
CRON does not execute
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
Re: CRON does not execute
Hello, PatrickLatour.
How do you know they are not executed?
Have you located the relevant entries in the logfile /var/log/syslog? What does syslog tell you about your 3 scripts?
Maybe they are launched by cron as designed, but fail to complete due to an error?
Have you added some internal logging functionality to your scripts so that they log their own actions to dedicated logfiles perhaps?
When scheduling the 3 scripts to run each Saturday and Sunday morning at 7:54, 7:55 and 7:56 respectively, have you kept in mind that they will not be run in case the machine is not switched on at the specified time? (This thought will be irrelvant provided your machine runs 24 hours a day.)
A very simple way of making your 3 scripts create their own logfiles which should hold all error messages as well would be changing your crontab lines look like this:
Kind regards,
Karl
If my counting is right, then you scheduled 3 separate scripts, not just 1.I have a cronjob that does not execute when scheduling.
How do you know they are not executed?
Have you located the relevant entries in the logfile /var/log/syslog? What does syslog tell you about your 3 scripts?
Maybe they are launched by cron as designed, but fail to complete due to an error?
Have you added some internal logging functionality to your scripts so that they log their own actions to dedicated logfiles perhaps?
When scheduling the 3 scripts to run each Saturday and Sunday morning at 7:54, 7:55 and 7:56 respectively, have you kept in mind that they will not be run in case the machine is not switched on at the specified time? (This thought will be irrelvant provided your machine runs 24 hours a day.)
As far as I know cron does not care about comment lines. There should be no need of having a trailing comment line. But maybe a particular cron version had a bug which made it ignore the last crontab line unless it was ended by a proper linefeed?3-) Notice the empty remark at the end, I read somewhere that it takes an empty line at the end.
/var/log/syslog should hold entries about all cron activities.Where in the logs can I see if cron returns an error ?
A very simple way of making your 3 scripts create their own logfiles which should hold all error messages as well would be changing your crontab lines look like this:
Code: Select all
54 7 * * 0,6 /home/patrick/Scripts/script01 > /home/patrick/Scripts/script01.log 2>&1
55 7 * * 0,6 /home/patrick/Scripts/script02 > /home/patrick/Scripts/script02.log 2>&1
56 7 * * 0,6 /home/patrick/Scripts/script03 > /home/patrick/Scripts/script03.log 2>&1
Karl
The people of Alderaan have been bravely fighting back the clone warriors sent out by the unscrupulous Sith Lord Palpatine for 762 days now.
Lifeline
Re: CRON does not execute
Thanks Karl, I will correct the scripts to make them generate a log and will see from there. The day and time the script should execute is not a problem since my machine is "ON" 24 hours a day. Another point I am thinking about some researches is probably an error generated du the PATH variables. Will have to investigate that side, depending of what I will see in the logs.
Regards,
Regards,
Re: CRON does not execute
Hello, PatrickLatour.
Forgot to mention:
It may be a good idea to source the user's .bashrc file in any script which is executed by cron in order to make sure the proper user environment gets loaded. At least this is the way how we do it on HP-UX. Maybe there is a more elegant way on Linux . If so, I have failed to find out which way. Guess I should study the man pages one more time.
Cheers,
Karl
Forgot to mention:
It may be a good idea to source the user's .bashrc file in any script which is executed by cron in order to make sure the proper user environment gets loaded. At least this is the way how we do it on HP-UX. Maybe there is a more elegant way on Linux . If so, I have failed to find out which way. Guess I should study the man pages one more time.
Cheers,
Karl
The people of Alderaan have been bravely fighting back the clone warriors sent out by the unscrupulous Sith Lord Palpatine for 762 days now.
Lifeline
Re: CRON does not execute
How about the internet connection, always running
and about the MAILTO variable, correct entry or not ?
http://service.futurequest.net/index.ph ... le/View/23
and about the MAILTO variable, correct entry or not ?
http://service.futurequest.net/index.ph ... le/View/23
- Can you use * for that element, I know you can for dates..
Re: CRON does not execute
I have the same problem.
In /var/log/syslog.1 I find
May 19 04:00:01 par-GF7100-7050PVT-M3 CRON[21142]: (root) CMD ( run-parts /etc/cron.backup)
May 19 04:00:01 par-GF7100-7050PVT-M3 CRON[21141]: (CRON) error (grandchild #21142 failed with exit status 1)
May 19 04:00:01 par-GF7100-7050PVT-M3 CRON[21141]: (root) MAIL (mailed 1 byte of output; but got status 0x00ff, #012)
May 19 04:01:01 par-GF7100-7050PVT-M3 CRON[21194]: (root) CMD ( run-parts /etc/cron.backup)
May 19 04:01:01 par-GF7100-7050PVT-M3 CRON[21193]: (CRON) error (grandchild #21194 failed with exit status 1)
May 19 04:01:01 par-GF7100-7050PVT-M3 CRON[21193]: (root) MAIL (mailed 1 byte of output; but got status 0x00ff
I have created a directroy called cron.backup in which I have a backup routine (and I plan to add more routines here) to be executed every night at 04:00. This worked like a charm in my old distro (Fedora 9), but in Mint 12 it does not fly.
Crontab setup:
.....
.....
02 4 * * * root run-parts /etc/cron.backup
In cron.backup (ls -l):
-rwx--x--x 1 root root 98 2012-05-08 12:00 ext-backup
ext-backup contains
date > /media/Expansion*Drive/par/ext-backuptime.log
cp /home/par/* -r /media/Expansion*Drive/par
and this has worked well until now.
In /var/log/syslog.1 I find
May 19 04:00:01 par-GF7100-7050PVT-M3 CRON[21142]: (root) CMD ( run-parts /etc/cron.backup)
May 19 04:00:01 par-GF7100-7050PVT-M3 CRON[21141]: (CRON) error (grandchild #21142 failed with exit status 1)
May 19 04:00:01 par-GF7100-7050PVT-M3 CRON[21141]: (root) MAIL (mailed 1 byte of output; but got status 0x00ff, #012)
May 19 04:01:01 par-GF7100-7050PVT-M3 CRON[21194]: (root) CMD ( run-parts /etc/cron.backup)
May 19 04:01:01 par-GF7100-7050PVT-M3 CRON[21193]: (CRON) error (grandchild #21194 failed with exit status 1)
May 19 04:01:01 par-GF7100-7050PVT-M3 CRON[21193]: (root) MAIL (mailed 1 byte of output; but got status 0x00ff
I have created a directroy called cron.backup in which I have a backup routine (and I plan to add more routines here) to be executed every night at 04:00. This worked like a charm in my old distro (Fedora 9), but in Mint 12 it does not fly.
Crontab setup:
.....
.....
02 4 * * * root run-parts /etc/cron.backup
In cron.backup (ls -l):
-rwx--x--x 1 root root 98 2012-05-08 12:00 ext-backup
ext-backup contains
date > /media/Expansion*Drive/par/ext-backuptime.log
cp /home/par/* -r /media/Expansion*Drive/par
and this has worked well until now.
Re: CRON does not execute
im getting same sort of issue its not executing and do not know why :/
my code is a lil different but it should work
so maybe its the actual program or something any ideas hoiw to fix it for us both ( i didnt want to create a new post as this is relevant to both the original poster and myself but i could make a new post if needed!
my code is a lil different but it should work
Code: Select all
*/5 * * * * php -f /var/www/html/cj/email1.php >/dev/null 2>&1
so maybe its the actual program or something any ideas hoiw to fix it for us both ( i didnt want to create a new post as this is relevant to both the original poster and myself but i could make a new post if needed!
Re: CRON does not execute
Just add the following to the start of the script:karlchen wrote:.... It may be a good idea to source the user's .bashrc file in any script which is executed by cron in order to make sure the proper user environment gets loaded. ....
Code: Select all
source ~/.bashrc
For example, I have the following in my .bashrc:
Code: Select all
export TEST="TEST"
Code: Select all
r00t@rc ~ $ source ~/.bashrc; echo $TEST
TEST
r00t@rc ~ $