May 24, 2002 #1 ManagerJay IS-IT--Management Joined Jul 24, 2000 Messages 302 Location 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
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
May 24, 2002 #2 RobJordan MIS Joined Apr 3, 2001 Messages 296 Location US 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. http://www.InYourMind.comFREE Unix Scripts Upvote 0 Downvote
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. http://www.InYourMind.comFREE Unix Scripts
May 24, 2002 Thread starter #3 ManagerJay IS-IT--Management Joined Jul 24, 2000 Messages 302 Location US 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 Upvote 0 Downvote
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