-4

My requirement -

  • I will schedule the job with cron expression.
  • The job is scheduled and runs every Monday morning 00:05 in the month
  • And it should run on the last Monday of the month.

Example : Consider this month I scheduled job for 3rd, 10th, 17th, 24th. I am expecting 24th job should not only run on 3rd, 10th, 17th , similar for all the month.

Nasir Riley
  • 2,300

1 Answers1

0

If you want it to run on a specific day, Monday, then you'll need to set it for the day of the week.

* * * * *

This is shown in the file /etc/crontab but to be clear, the asterisks represent, from left to right:

minute hour day of month month day of week

Right now, you have it set for those dates but clearly you don't want that because those dates won't always be Monday. To get what you want, use the following:

5 0 * * MON user command

That will run the job at 5 minutes after midnight or (12:05AM or 00:05AM) every Monday regardless of what date the Monday is.

Nasir Riley
  • 2,300