-1

I am trying to setup a cron job on a Ubuntu server. I want the cron job to run the script on weekly basis. Problem is - It should be a working day, If im mentioning it with time interval, it fails during weekoffs - Need an Schedular Exp which has to work weekly only on working days at office hours.(9am to 9pm)max.

Want to Execute the script every week @6 pm during the weekdays. It Can be Mon to Fri.

  • Well, what prevents you from doing it? Please read [ask] and then show what you've tried and where exactly you failed. – Thomas Aug 21 '19 at 11:27
  • Possible duplicate of [setup cron tab to specific time of during weekdays](https://stackoverflow.com/questions/14436953/setup-cron-tab-to-specific-time-of-during-weekdays) – Haripriya Aug 21 '19 at 11:30
  • The tag `java` has nothing to do with your question, remove it. – improbable Aug 21 '19 at 11:33
  • @improbable probably not. cron exp is a common exp for a spring boot java apps – Yuriy Tsarkov Aug 21 '19 at 11:36
  • @YuriyTsarkov Only if you are using Scheduled of the Spring Framework. But, in fact, there is nothing about Java and/or Spring Framework in the actual question and there is no java code/snippets at all which makes me think the question has nothing to do with Java/Spring at all. And even if it would be a a case, spring tag must in place, not java. – improbable Aug 21 '19 at 11:43
  • sorry , ill keep tat in mind for next time.. tq @thomas – Aby Sebastin Aug 21 '19 at 12:16
  • “At every 2nd minute past every hour from 9 through 18 on every day-of-week from Monday through Friday.” @PriyankaW - This is what the expression for the Cron. I need something like - which has to be executed weekly at Sometime only on WeekDays. – Aby Sebastin Aug 21 '19 at 13:12

1 Answers1

0

Step1

sudo apt-get install cron

systemctl status cron

Step2 Configure the cron job:

crontab -e

Select an editor of your choice

0 0 * * 0 /path/to/command

Syntax: minute hour day-of-month month day-of-week command.

Day-of-week goes from 0-6 where 0 is Sunday.

Save it.

Nandy
  • 341
  • 3
  • 5