Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

cron permissions

Status
Not open for further replies.

ManagerJay

IS-IT--Management
Jul 24, 2000
302
US
How do I specify a path for cron to use when running a script?

I am running a perl script in RedHat 7.2.

Thanks for your help.



Jay
 
I'm not sure that you can do that.
I would use the absolute path to run the command.

for example
3 0 * * * /usr/bin/ls
instead of
3 0 * * * ls

If you are calling a script rather than a single command,
make sure the script uses absolute paths as well.

Another option is to have the script cd in to a directory
or export a PATH before running any commands if you
are using relative commands.

To be on the safe side,
I always use absolute paths in scripts.
You can still shorten your commands by using variables.

For example:
BASE_DIR=/prod/users/scripts
$BASE_DIR/script1
$BASE_DIR/script2


Robert G. Jordan
Unix Sys Admin
Sleepy Hollow, Illinois U.S.A.
sh.gif


FREE Unix Scripts
 
Thanks for the help. I figured I would have to export a path, but I was hoping for an easier solution.

Have a nice weekend.


Jay
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top