1836374 Members
2201 Online
110100 Solutions
New Discussion

cron job not working!

 
Mark Porter_1
Occasional Contributor

cron job not working!

 
6 REPLIES 6
PC_7
Frequent Advisor

Re: cron job not working!

Hi,

Is "cron job not working" the only prob description? Could you pls elaborate more on that? Thanks..


Rgds,
Pau Cen
Rainer von Bongartz
Honored Contributor

Re: cron job not working!

Normally no further explanation is needed; according to my experience 99 % of 'not working cron jobs' come from the fact that cron jobs have no correct environement set !! All settings from the shell (especially $PATH) are not know in a cron job. Specify a correct environement in your job and cron will work.


Regards
Rainer
He's a real UNIX Man, sitting in his UNIX LAN making all his UNIX plans for nobody ...
Sridhar Bhaskarla
Honored Contributor

Re: cron job not working!

Make sure that your cronjob is listed with the command

crontab -l

It doesn't harm if you run this command

crontab -l > my_cron_file

crontab my_cron_file

Also you can check if the job ran or not in /var/adm/cron/log file

-Sri
You may be disappointed if you fail, but you are doomed if you don't try
Magdi KAMAL
Respected Contributor

Re: cron job not working!

Hi Mark,

1.Ensure that there is something planned with crontab :
#crontab -l [UserName]
without username , stands for root.

2. Verify that the syntaxe is OK inside the crontab file :

minutes hour monthday month weekday command

minutes : 0-59
hour : 0-23
monthday : 1-31
month : 1-12
weekday : 0-6 ( 0 is sunday )

3. Ensure ( very important ) that the envirenment profile file for a specific user is executed at the begining of the crontab job :

. /home/users/.../.profile

4. Ensure that the process /usr/sbin/cron is running.

Magdi
Robin Wakefield
Honored Contributor

Re: cron job not working!

All,

I think you'll find Mark's empty query was actually posted with the text 3 mins. later:

http://forums.itrc.hp.com/cm/QuestionAnswer/1,1150,0x095f1012aa92d5118ff10090279cd0f9,00.html

Rgds, Robin.
Magdi KAMAL
Respected Contributor

Re: cron job not working!

Hi again Mark,

The command in the crontab file, in my last post, should by in absolute path to avoid any miss of environment setting. Like :

examples :

0,30 12,17 * * * /home/users/checkSpace.sh

This command checks space all at :
- zero and 30 minutes ( You can add other minutes with comma separator ).
- 12 and 17 hour ( You can add other hours with comma separator ).
- All days in month ( * stand for all days, you still can add any days in month with comma separator).
- All months in year ( * stand for all months, you still can add any months in year with comma separator).
- All days in week( * stand for all days, you still can add any days in week with comma separator).


Magdi