0

I have this on my crontab

10 6 * * * java -jar /.../myproject.jar >> /../myjob.log 2>&1

I want run my app only the week (Monday to Friday)

This line is ok ? :

10 6 * * 1-5 java -jar /.../myproject.jar >> /../myjob.log 2>&1
3

That is a correct way to run the job on days 1 through 5 (Sunday being 0 (or 7)). Alternatively, you could explicitly list the days:

10 6 * * 1,2,3,4,5 java -jar /.../myproject.jar >> /../myjob.log 2>&1

You'll want to be careful about adding a "day of month" (field 3) restriction, apart from *; if both values are specified, then cron will run the job when either field matches.

  • +1 for pointing out day-of-week + day-of-month strange behavior (OR instead of AND) – Archemar Mar 9 '18 at 16:05
1

Yes, that looks right.

10 6 * * 1-5 java -jar /.../myproject.jar >> /../myjob.log 2>&1

This would run the command at 06:10 (6.10am) every week day (Monday to Friday).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.