I want to set up a cron job which will execute a command every hour. However, I want that this command should be started at 10 A.M and should run every hour till 4 P.M. This job is to run daily between these times. The command is nothing but a call to a Perl script. Following crontab entry runs fine and invokes the script every hour
* */1 * * * cd path_to_file; perl file.pl > path_to_logs/log.txt
Is there a way to limit the timings of this cron job so that it runs only between 10 A.M and 4 P.M ?
man 5 crontabis your friend. (Your example does not do what you claim it does;/1is the default skip and therefore redundant, and that spec therefore runs once per minute due to the leading*instead of0.)(I used 15, because it occurs to me that “between 10 and 4” is an exclusive range so you don’t want to run at 16:00.)