Operating System - HP-UX
1826498 Members
1896 Online
109692 Solutions
New Discussion

Re: command to execute a script periodically

 
Jeffrey Shannon
Contributor

command to execute a script periodically

I have written a sript to send the outputs of useful commands to a file, and to e-mail the file in case the server were to go down. However, I'd like to execute this script approximately once or twice a week. Is there a command that I can put into the script to do this?
7 REPLIES 7
Craig Rants
Honored Contributor

Re: command to execute a script periodically

Jeffery,
Use the cron utility.

As root enter the command crontab -e

at the end of your vi session enter

# "Description of script"
00 3 * * 5 "Absolute Path of Script" > /dev/null 2>&1

Good Luck,
C
"In theory, there is no difference between theory and practice. But, in practice, there is. " Jan L.A. van de Snepscheut
Craig Rants
Honored Contributor

Re: command to execute a script periodically

Forgot to tell you that this would execute the script at 3am on the 5th day of the week which is Friday.

C
"In theory, there is no difference between theory and practice. But, in practice, there is. " Jan L.A. van de Snepscheut
Uday_S_Ankolekar
Honored Contributor

Re: command to execute a script periodically

Hi,
Cron is the tool for this

man crontab for more details and look for examples.
It is pretty simple to setup.

Goodluck,
-USA..
Good Luck..
Sanjay_6
Honored Contributor

Re: command to execute a script periodically

Hi Jeff,

You can use cron to schedule execution of a command/script. Use man crontab for more help.

Regds
harry d brown jr
Honored Contributor

Re: command to execute a script periodically

Jeffery,

A more useful approach would be this: Make a make_recovery tape every night - takes less than an hour and saves countless hours of headaches when you do have server issues. Also, mirror your rook disk. If you need help with these commands, then post a new question.

live free or die
harry
Live Free or Die
Krishna Prasad
Trusted Contributor

Re: command to execute a script periodically

cron or at will work...

I would use cron
Positive Results requires Positive Thinking
Dave La Mar
Honored Contributor

Re: command to execute a script periodically

Jeffrey -
I built the following based on tips from the forum. Insure the admin has your login in the cron.allow file. Then crontab -e, and input your min.,hour,date, month, day,and script to execute.

# min hour date month day command
# 0-59 0-23 1-31 1-12 0-6 redirect the output
# 30 6 * * * /home/dlamar/work/omaha/omahaftp
0 7 * * 1-5 /home/dlamar/work/bklogs/userbk.log
30 14 * * 5 /home/dlamar/work/bklogs/makrec.log


dl
"I'm not dumb. I just have a command of thoroughly useless information."