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!

Running Shell Script in Crontab

Status
Not open for further replies.

johnnyasterisk

IS-IT--Management
Apr 2, 2008
26
IE
Hey guys...


I have a shell script in a directory /home/mydir called getfiles.sh i want to run it every night however my problem is the file needs to run in its own directory because it needs to access stuff in there. Is there a way I can tell crontab to move into this directory before running the script?

I know I could rewrite my script to use the full path, just wondering if above is possible.
 
Something like this:

Code:
00 00 * * * cd /home/mydir ; ./getfiles.sh > getfiles.out 2>&1

Annihilannic.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top