How to automatically run a .sh file in Centos - SSH

Stillie

Expert Member
Joined
Dec 10, 2009
Messages
3,216
Reaction score
308
Location
Cape Town
Hi guys and gals,

i would like to schedule a .sh file to run automatically every say 6 hours. all it basically does is copies files from one location to another(other being Dropbox)

Thanks gurus

PS im new to SSH and command line linux so give me a break here :)
 
Hi guys and gals,

i would like to schedule a .sh file to run automatically every say 6 hours. all it basically does is copies files from one location to another(other being Dropbox)

Thanks gurus

PS im new to SSH and command line linux so give me a break here :)

Hey - how about using crontab to schedule your script?

Just "crontab -e" to edit. For example the below would run your script at 00:00, 06:00, 12:00, 18:00:

1) crontab -e (an editor like vi will open)
2) * 00,06,12,18 * * * /home/stille/myscript.sh >/dev/null 2>&1
3) save and quit
4) crontab -l (to view what you configured)
 
Also..

1. Make sure you have th correct shebang set i.e. the 1st line #!/bin/bash assuming bash
2. Make it executable, i.e. chmod +x somefile.sh
 
Top
Sign up to the MyBroadband newsletter
X