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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

executing a shell script in crontab

Status
Not open for further replies.

pearlofperls

Technical User
Apr 5, 2007
24
US
Im trying to execute a shell script in crontab, however the script needs an option to be specified to work. I dont know how to get this to work.

- I have called the shell script with option as entry in the crontab

- I have nested the shell script with option in another shell sciprt and called that one from crontab and have no luck either.

Any suggestions?
 
Are you sure that it the option that is causing it to fail. there's no reason why a crontab line like
Code:
* * * * * /usr/local/bin/myscript -flag
shoudn't work.

The normal reason why cron entries fail is that the shell variables aren't set properly. When you run a script from the command line all the settings from /etc/profile, ~/.profile etc are available. When you run from cron they aren't. Try adding the line
Code:
. ~/.profile
somewhere near the top of your script or try
Code:
* * * * * su - root -c "/usr/local/bin/myscript -flag"

Ceci n'est pas une signature
Columb Healy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top