Jump to content

Recommended Posts

Posted

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

Posted

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 

 

 

 

  • Thanks 1
Posted

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.

Posted
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

Posted
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!

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 account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...