Computing.Net > Forums > Unix > Scheduling a batch run

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Scheduling a batch run

Reply to Message Icon

Name: simflex
Date: March 15, 2007 at 08:15:47 Pacific
OS: unix
CPU/Ram: 2g
Product: don't know
Comment:

We have about 50 scripts that we run everyday.

How can we schedule this script to run automatically on the 5th of every month?

I can provide info if needed.

Thanks in advance



Sponsored Link
Ads by Google

Response Number 1
Name: nails
Date: March 15, 2007 at 08:49:38 Pacific
Reply:

The unix cron utility is typically used to execute schedule jobs. Consider the contents of myfile:

0 0 5 * * /path/to/myscript

The myscript script now executes at midnight on the 5th.

Make sure that myscript contins the shell you want to execute since cron uses /bin/sh by default. Also, make sure myscript has PATH set.

This command sets cron for whatever user you are logged in as:

crontab < myfile

overwrites any previous cron.

Off topic: If you have scripts that share resources, you might check out:

http://www.samag.com/documents/s=92...


0

Response Number 2
Name: simflex
Date: March 15, 2007 at 11:38:10 Pacific
Reply:

Thank you so much for your response.

Can I follow up, please?

You said:
>>Make sure that myscript contins the shell >>you want to execute since cron >>uses /bin/sh by default. Also, make sure >>myscript has PATH set.

How do I get shell and how do I ensure it?

Please be patient. I am a web developer and this just got dropped on my laps because the current owner of the project left.

thanks again



0

Response Number 3
Name: nails
Date: March 15, 2007 at 12:11:20 Pacific
Reply:

OK, some lazy shell programmers don't place in the script which shell they are using; they rely on how their environment is set which might be different from the cron utility.

On the first line of the shell script in the first column, you should see this line if it's a bourne script:

#!/bin/sh

If it is a korn shell script:

#!/bin/ksh

Take a look here for a comprehensive list of available shells:

http://www.allcommands.com/samples/...

The second thing I mentioned was PATH.

If your scripts are running correctly at the command line, check your PATH variable:

echo $PATH

Make sure the PATH is set within the scripts that will be run from cron:

PATH=...
export PATH


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: Scheduling a batch run

changing dir's with a batch file? www.computing.net/answers/unix/changing-dirs-with-a-batch-file/704.html

Scheduling events in UNIX www.computing.net/answers/unix/scheduling-events-in-unix/2864.html

Running a Java class in the crontab www.computing.net/answers/unix/running-a-java-class-in-the-crontab/4076.html