Link to home
Start Free TrialLog in
Avatar of chsoh
chsoh

asked on

cron job

I have a reschedule daily cron job process to purge some database record at the end of the day. The process worked fine with more than 6 month.

Recently, the cron job event has been missing and never reschedule. why ?

For more information, the owner of the job has a right access mode & has a never expired password.

Avatar of yuzh
yuzh

Is the job still define in the crontab ?

Do you have a log file for the job?

Have a look at your crontab and log file, and try to run the script in command line see what happen.
Have a look in /var/cron/log to see the status of the job.
Avatar of chsoh

ASKER

Need to know if the following line mean the server is restarted ?

I have a cron job at 3am but server restarted at 3.01am




> userXXX 2993 a Tue Nov 12 03:00:00 2002
! SIGTERM Tue Nov 12 03:01:39 2002
! ******* CRON ABORTED ******** Tue Nov 12 03:01:39 2002
! *** cron started ***   pid = 182 Tue Nov 12 03:03:43 2002
Avatar of chsoh

ASKER

Need to know if the following line mean the server is restarted ?

I have a cron job at 3am but server restarted at 3.01am




> userXXX 2993 a Tue Nov 12 03:00:00 2002
! SIGTERM Tue Nov 12 03:01:39 2002
! ******* CRON ABORTED ******** Tue Nov 12 03:01:39 2002
! *** cron started ***   pid = 182 Tue Nov 12 03:03:43 2002
Have you/or someone installed any new software or patches on the systems in the last few months ? (I mean from the time the cron job stop working).

Have you try to run the script in the command line to verify if it still work ?

Try to change the starting time to 3.05am to see what happen.
Doing a 'who -b' or uptime will tell you when the server was last rebooted.

Do you have some other cronjob that runs around that time and does a reboot?
I just wonder why do you guys want to reboot a UNIX box every day.

I keep all my boxes running unless there is a power outage, or OS update required a reboot.
can you do an crontab -l and paste it also let us see your /var/cron/log file, also check to see if there is any mail for the user who runs the cron job, and also paste that here, the more information we have the better.
Anything new ?
Avatar of chsoh

ASKER

The news : Find out the missing job is handle by <at> command.

if the job takes minimum 20 minutes to complete, what happen if we restart the server.

will <at> command re-schedule it ?

Anyone please simulate for me because I am not allow to restart the server.

1) <at> schedule a daily job and will take apprx 20 minutes to complete
2) When the job start, shutdown system immediately
3) bootup system
4) check the <atq>

When the system shultdown, the "at" or "cron" job will get killed, after the system is reboot, the job miss out the starting time, it will not run it for the same day, eg if you schedule a job at 3.00am, and your system reboot at 3.05, how can you get the time back to 3.00am for the same day. My advise is that avoid to run any cron job when the system is about to shultdown. Schedule the job start at a different time.



Avatar of chsoh

ASKER

ok, nevermind if I miss out today 3am job.
but what happen to the next day process ? will system trigger my process again at 3am tomorrow?

actually my 3am daily job is to purge the old records from database. eg
DELETE from tableXYZ
where date < today.

I dont have a problem if the system trigger my program again for tomorrow 3am. The main problem now is the job missing FOREVER and never reshedule again.

why.

X-file.

I don't know if your system is rebooting at 3.00am everyday? If not to can put the job in your crontab. Let's say to want to run the job as user fred, put the following in the crontab (root)

0 3 * * * su - fred -c "/path-to/yourscript"  >/dev/null 2>&1

it will run, for 3.00am everyday if the system is not rebooting !

If you know your system is always reboot at 3.05, start at 3.30am:

30 3 * * * su - fred -c "/path-to/yourscript"  >/dev/null 2>&1

If your script has args, just put them inside the ""

eg:

0 3 * * * su - fred -c "/path-to/yourscript arg1 arg2 "  >/dev/null 2>&1



Avatar of chsoh

ASKER

ok, nevermind if I miss out today 3am job.
but what happen to the next day process ? will system trigger my process again at 3am tomorrow?

actually my 3am daily job is to purge the old records from database. eg
DELETE from tableXYZ
where date < today.

I dont have a problem if the system trigger my program again for tomorrow 3am. The main problem now is the job missing FOREVER and never reshedule again.

why.

X-file.

Avatar of chsoh

ASKER

my system will reboot 5am everyday.

I not sure what is the cause to manually reboot the system for that day. What I wonder now is why the system reboot before my program finished and cause my batch never exist in the batch.
(my tomorrow's job never exist in <atq> anymore)

I have to run <at> command to add in the daily process again.


Ask you sys adm why he want to reboot the system every day?

If you don't want to run "at" dailly, ask your sys adm to put it in the crontab to make it automatically doing the job for you. change the starting time to 5.30am if the system reboot at 5.00am.

Good luck

Avatar of chsoh

ASKER

hi yuzh,

This is not an operational error.

Anyway, You know what is the differences between <crontab -e> and <at> command to queue the job ?

Scheduling jobs via 'at' differs from cronjobs as it will use your current environment.

I a cronjob, you must make sure you set all the additional paths, environment variables explicity.
Hi Tintin,

   Did you read my previous comments( and example)

 eg:

0 3 * * * su - fred -c "/path-to/yourscript arg1 arg2 "  >/dev/null 2>&1


   su - fred -c "command"
   means what? run the "command" use user "fred"'s Environment settings !




Hi yuzh.

Yes I did read your previous comments.  I was responding to chsoh's questions about the difference between 'at' and cronjobs.
Avatar of chsoh

ASKER

can we schedule the job like
Run script <abc.sh> Daily 1pm, from month January to June only ??
ASKER CERTIFIED SOLUTION
Avatar of yuzh
yuzh

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of chsoh

ASKER

how about <at> command ?
If you want to do the equivalent as an 'at' job, then you are going to have to schedule 180 separate 'at' jobs.  I know which one I'd rather type in.