How to Set Up a Cron Job That Only Runs on Weekdays


For maximum organizations, you handiest paintings on weekdays – Monday via Friday. In one of these case, some duties will have to handiest execute on weekdays and no longer on weekends. It can be a process like sending emails, checking attendance, or developing backups. Whatever the duty, there’s a approach to automate it to just execute at a selected time each day on weekdays. To reach that, you should utilize the Linux cron application. If you don’t have any thought methods to use the crontab to time table some duties that handiest run on weekdays, learn on to determine.

How to Schedule Tasks Using Cron on Linux and Unix

There are quite a lot of tactics to make use of the cron to time table duties. But the average approach comes to specifying the date and time. To do that, a specified command is accomplished. The secret comes to using the 5 fields of a crontab command to outline which day the command will have to execute.

Here, the methods lie in the use of the particular characters and, particularly, the hyphen (-) which supplies a listing of the values to make use of for a given box.

The syntax for the crontab is as follows:

Min Hour Day-of-month Month Day-of-week [command]

Our focal point is at the Day-of-week. The allowed values are 0 to six, the place 0 is Sunday and six is Saturday. Therefore, to specify a command that runs handiest on weekdays, we set the Day-of-week to 1-5 without a areas.

The command can be:

The given syntax specifies no explicit time that the command will have to execute. If you had to set it to run each and every weekday at 10:00 AM, the command can be:

Now, upload the next command on the backside of your crontab record via operating the command that follows:

Save the record and go out.

You now have a cron process for the present consumer. If you run a script like on this case, make certain to offer its complete trail.

Other Options to Run a Command on Weekdays

There are quite a lot of tactics to set a command that runs on weekdays. Let’s have some examples:

1. Weekdays of a Given Month

Not each and every month is a operating day. Therefore, chances are you’ll want to execute your cron process at a specific month handiest. For this, you’ll specify the month via the use of the month quantity the place 1 represents January. To handiest run the similar command on January at 10:00 AM, alternate it to mirror the only within the following:

2. Weekdays and Specific Days of a Given Month

Some duties can also be scheduled to run on a given day of a given month, equipped it’s a weekday. For example, chances are you’ll set a backup script that runs at the 5th day of January on weekdays and at a given time. The command for that will be:

In the former instance, we specified that the named script is to execute at 10:00 AM at the 5th day of January from Monday to Friday.

The base line is that you’ll alternate the quite a lot of fields to tweak when the command will have to execute on weekdays handiest. You can select which month it will have to run or specify a spread. Moreover, you’ll set the precise time or use an period at a specific hour to check your want.


We lined how you’ll use the crontab to time table a task that runs handiest on weekdays. Furthermore, we realized the opposite ways in which you’ll mess around with the opposite fields to be extra explicit at the day of the month, hour, minute, and month that your command will have to run. Try it out!

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More