FN-GM Posted May 3, 2018 Posted May 3, 2018 Hello, I have a .sh script I wish to run by Cron every hour on a CentOS box. 1. What folder should I place the .sh file please? 2. Would this Cron config work please? 0 */1 * * * .folder/script.sh Thanks
mjk Posted May 3, 2018 Posted May 3, 2018 0 */1 * * * will run every one hour. If you put the script in: /etc/cron.hourly/ it will do the same thing and you won't need the cron config. Remember to make the script executable chmod u+x /etc/cron.hourly/script.sh 1
Arthur Posted May 3, 2018 Posted May 3, 2018 (edited) 2. Would this Cron config work please? 0 */1 * * * .folder/script.sh Yes. https://crontab.guru/#0_*/1_*_*_* Edited May 3, 2018 by Arthur 1
SHimmer45 Posted May 3, 2018 Posted May 3, 2018 crontab guru is VERY useful, spent ages attempting to sort out a schedule and someone suggested i look at it. seeing it on screen suddenly made the examples and manual make sense.
keithu Posted May 3, 2018 Posted May 3, 2018 Hello, 1. What folder should I place the .sh file please? 2. Would this Cron config work please? 0 */1 * * * .folder/script.sh You really need to use an absolute path when referencing your script as there is no guarantee that .folder/script.sh will be on the PATH. Like this: 0 */1 * * * /path/to/my/folder/script.sh However, as CentOS already has cron.hourly already set up you might as well use that. What I generally do is keep all my scripts in a directory called /etc/scripts and then symlink them into the appropriate cron directory. ln -s /etc/scripts/script.sh /etc/cron/cron.hourly/script.sh
FN-GM Posted May 3, 2018 Author Posted May 3, 2018 If you put the script in: /etc/cron.hourly/ it will do the same thing and you won't need the cron config. Remember to make the script executable chmod u+x /etc/cron.hourly/script.sh This worked a treat! Thanks!
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now