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

2 Answers 2

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
  • +1 for pointing out day-of-week + day-of-month strange behavior (OR instead of AND)
    – Archemar
    Commented Mar 9, 2018 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).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .