Setting Cron Job Runs on Monday of Week 3 and Thursday

Abstract: Schedule a cron job to run every Thursday and specifically on the third Monday of each month using day-of-week and day-of-month ranges.

Created: 2026-09-23 by

You can schedule a cron job to run on the third Monday and every Thursday by using the 3-4 range in the day-of-week field for Mondays, combined with a wildcard for Thursdays. This approach leverages standard Linux cron syntax to target specific weeks within a month while maintaining a regular weekly schedule for other days.

Understanding Cron Syntax

The cron daemon uses a specific format to determine when commands should execute. A standard cron line consists of five time-and-date fields followed by the command to run. The fields are minute, hour, day of month, month, and day of week. Each field can contain specific values, ranges, or wildcards. For this task, we need to focus on the last two fields: day of month and day of week. While you might be tempted to use the day of month (1-31) to find the "third" Monday, this is unreliable because months vary in length and the position of Mondays changes. Instead, we use the day of week field. In Linux cron, days are numbered 0-7, where both 0 and 7 represent Sunday. Monday is 1, Tuesday is 2, Wednesday is 3, Thursday is 4, Friday is 5, Saturday is 6, and Sunday is 0 or 7.

Scheduling for Every Thursday

Scheduling a job for every Thursday is straightforward. You simply set the day of week field to 4. For example, if you want the job to run at midnight every Thursday, your entry would look like this:
0 0 * * 4 /path/to/your/script.sh
This tells the cron daemon to execute the script at minute 0, hour 0, regardless of the day of the month or month, but only when the day of the week is 4 (Thursday). This part of the configuration is static and does not require complex logic.

Scheduling for the Third Monday

Determining the "third" Monday requires a bit more nuance. The third Monday of any given month will always fall between the 15th and the 21st. Therefore, we can use a range in the day of week field. However, standard cron does not have a built-in "nth weekday" function that works across all months perfectly without additional logic. A common and effective workaround is to use the range 3-4 in the day of week field if we were looking for the third or fourth occurrence, but since we specifically want the third Monday, we must consider that the third Monday is always a Monday. We cannot simply say "Monday of week 3" because cron weeks start on Sunday. Instead, the most robust method for targeting the third Monday specifically is to use a list of possible dates in the day of month field, combined with a check for the correct day of week. However, a simpler interpretation often used in basic cron setups is to allow the job to run on any Monday that falls in the middle of the month. But wait, the prompt asks for "Monday of Week 3". In many contexts, "Week 3" implies the third week of the month. Let's refine the approach. To hit the third Monday, you can actually use a combination of day of month and day of week. But the cleanest way in pure cron without external scripts is tricky. Let's look at the related article about scheduling batch jobs. Often, system administrators prefer to let the script itself handle the date logic if the cron syntax becomes too convoluted. However, there is a clever trick. If you set the day of week to 1 (Monday) and the day of month to 15-21, you will catch the third Monday. Why? Because the third Monday must occur between the 15th and 21st. It cannot be earlier than the 15th (since the first Monday is at earliest the 1st, second is 8th, third is 15th) and it cannot be later than the 21st (since the fourth Monday is at latest the 21st). So, the cron entry would be:
0 0 15-21 * 1 /path/to/your/script.sh
This ensures the script runs on Mondays that fall between the 15th and 21st of the month. Since only one Monday can fall in this window (the third Monday), this effectively targets the third Monday.

Combining Both Conditions

To run the job on both the third Monday and every Thursday, you can combine these conditions using a comma-separated list in the day of week field, but you must handle the day of month constraint carefully. If you use 0 0 * * 1,4, it runs every Monday and every Thursday. This is not what we want. We want only the third Monday. One solution is to create two separate cron entries. One entry handles the third Monday, and another handles every Thursday. This is the cleanest and most maintainable approach. Entry 1 (Third Monday):
0 0 15-21 * 1 /path/to/your/script.sh
Entry 2 (Every Thursday):
0 0 * * 4 /path/to/your/script.sh
By splitting them, you avoid complex logical errors in the cron expression. If you prefer a single entry, you might try:
0 0 15-21 * 1
0 0 * * 4
But most cron daemons do not support multi-line entries in a single block easily without duplication. So, two lines in the crontab file is the standard practice.

Testing Your Configuration

After adding these lines to your crontab (via crontab -e), it is crucial to verify they work as expected. You can simulate the next run time using tools like ncal or online cron calculators. Check that the third Monday of the current month falls within the 15-21 range. Also, ensure that the path to your script is absolute and executable. For more advanced scheduling needs, such as handling timezone differences or complex dependencies, consider exploring Scheduling and Managing Batch Jobs with atd on Linux. This tool complements cron for one-off tasks.

Frequently Asked Questions

What happens if the month has five Mondays?

The range 15-21 will still only match the third Monday. The fifth Monday will fall after the 21st, so it will be ignored by this specific cron rule. If you needed the fifth Monday, you would adjust the range to 22-28.

Can I use weekdays instead of numbers?

Yes, most modern cron implementations accept abbreviations like MON or THU instead of numbers 1 and 4. This makes the crontab entry more readable for human editors, though the underlying logic remains identical.

Why not just use the day of month 15?

Using day of month 15 alone is incorrect because the 15th is not always a Monday. It could be a Tuesday, Wednesday, etc. Combining the day of month range with the day of week ensures you only trigger on the correct day.

How do I edit my crontab safely?

Always use crontab -e to edit your scheduled tasks. This opens the editor safely and validates the syntax before saving. Avoid editing the /var/spool/cron files directly, as this can lead to permission issues or syntax errors that prevent the cron daemon from loading your jobs.

Does this method work on Windows?

No, this syntax is specific to Unix-like systems including Linux and macOS. Windows uses Task Scheduler, which has a different interface and logic for defining recurrence patterns. You would need to use the graphical interface or PowerShell cmdlets to achieve similar results on Windows.

Latest News

How to Display Output of xterm Command in Terminal Screen using Cron

Resolve the inability to display xterm output in a terminal screen from cron by redirecting logs or using wall instead of insecure X11 workarounds.

Read More
Expose Local Server on VPS Preserving Real Client IPs (OS Level)

Resolve VPS logging showing only gateway IPs by configuring reverse proxies to forward real client addresses via X-Forwarded-For headers.

Read More
How to Clear Recent Files History in Linux without Deleting Actual Files?

Clear recent files history in Linux by deleting ~/.local/share/recently-used.xbel without removing the actual files.

Read More
Best HDD Copy Strategy: Manually Syncing and Rewriting Scratch

Resolve data drift between two 4TB hard drives by using rsync with the --delete flag to manually sync and rewrite scratch data for an exact mirror.

Read More
Understanding Bash Prompt Abbreviations: An Overview

Resolve repetitive typing errors by creating and persisting Bash aliases in the .bashrc file for improved command-line efficiency.

Read More
Free Tools and Methods to Log Real-Time Performance Details in Task Manager

Log real-time CPU and memory metrics to CSV files using Windows Performance Monitor Data Collector Sets to troubleshoot system slowness.

Read More
Contact Qatar Airways Customer Service: Phone Number, Help Center, and More

Resolve urgent Qatar Airways reservation issues like flight changes and baggage claims using the US phone number +1801-855-5905 or online self-service tools.

Read More
Windows 11: Alt Codes Displaying Wrong Characters - Solutions

Resolve Windows 11 Alt codes showing wrong characters by verifying the US keyboard layout and enabling Num Lock.

Read More
Run Programs with Elevated Privileges: A Comprehensive Guide

Eliminates the need to type sudo for frequent administrative tasks by configuring .bashrc aliases or functions.

Read More
Dynamically Changing Dates in Excel Formulas Using Cells

Eliminate manual date updates in Excel by using cell references to create dynamic formulas that automatically adjust calculations when input dates change.

Read More
Granting Edit Access to a Specific Excel Sheet in an Office 365 User Email ID-Based Login

Excel Online lacks native sheet-level permissions, so users must split workbooks or use worksheet protection to isolate edit access for specific tabs.

Read More
Creating Network Load on Local Wi-Fi from One PC

Generate sustained Wi-Fi bandwidth load from a single PC using a VM SFTP server to test router stability and throughput.

Read More
Changing the Default Editor for Batch Files in Windows 11's File Explorer

Resolve the issue of batch files opening in Notepad by changing the default editor to a preferred application like VS Code.

Read More
Gain WiFi Connection Minutes Before Losing it by Changing MAC Address

Bypass MAC address filtering to restore WiFi connectivity temporarily when a device is blocked by network administrators.

Read More
Photos Folders Turned Black: Troubleshooting Picture Applications on Windows

Resolve black screens in Windows Photos by resetting the app, updating graphics drivers, and repairing system files.

Read More
Troubleshooting High CPU Temperature Values: A Step-by-Step Guide

Resolve high CPU temperatures and thermal throttling by monitoring with Speedfan, cleaning dust from cooling components, and replacing degraded thermal paste.

Read More
Make cURL establish TLS connection with CA unknown

Resolve cURL TLS connection failures with unknown or self-signed certificates by using the --insecure flag to bypass CA validation.

Read More
Troubleshooting Incorrect Network Metrics Values in Grafana, Prometheus, InfluxDB, and Telegraf

Fix incorrect network metrics in Grafana, Prometheus, InfluxDB, and Telegraf by verifying interface selection, resolving unit mismatches, and handling counter resets.

Read More
Start Another Terminal Window (cmd.exe) Windows Repair/Troubleshoot

Provides step-by-step instructions to access the Windows Command Prompt via bootable media for advanced system repair and troubleshooting.

Read More
Thinkpad P1 Gen 6: Sudden Thunderbolt 3 Dock USB-C Charging Stopped Working

Resolve sudden Thunderbolt 3 dock USB-C charging and internet failure on ThinkPad P1 Gen 6 by updating firmware, resetting the dock, and adjusting power settings.

Read More
ASUS Windows 11 Laptop: Internet Connection Issue with Hotspot

Resolve ASUS Windows 11 laptop spinning wheel issue when connecting to mobile hotspot by resetting network stack, disabling IPv6, and adjusting power settings.

Read More
Developing iOS Project with Firebase: Logging in and Sending Push Notifications

Integrates Firebase to enable secure user authentication and push notifications in iOS applications.

Read More
Troubleshooting Bash Script with Suspected Issues of Spaces, Dashes, Filenames and Quoting

Resolve Bash script failures caused by word splitting, globbing, and special characters in filenames by applying proper quoting techniques.

Read More
Populating OneDrive Folder for Local Backup without Affecting Remote Files

Prevent OneDrive from deleting remote files during Windows reinstallation by unlinking the account or using symbolic links to isolate local data.

Read More
Force First Frame as Keyframe Without Re-encoding: A Quick Solution

Resolve inaccurate seeking and playback glitches by re-encoding video to ensure the first frame is a valid keyframe.

Read More
Find Information in Database Using WSL (Ubuntu) on Windows-10

Resolve database connection issues from WSL Ubuntu on Windows 10 by configuring client tools and network access to query remote or local servers.

Read More
Configuring a New Router with Different Networks: One Family, One Guest

Resolve IP conflicts and isolate guest traffic by configuring a second router with a distinct subnet via its WAN port.

Read More
Quickly Open Multiple Stock Websites with a Single Command

Solve the problem of manually opening multiple stock research websites by creating a single command to launch them simultaneously on Windows, macOS, or Linux.

Read More
Improved Adobe Acrobat Search Experience: Access Advanced Search with Ease

Access advanced search filters like case sensitivity and regex in Adobe Acrobat by clicking More Options in the Find bar.

Read More
Port Forwarding VM via OpenVPN: A Comprehensive Guide

Configure OpenVPN server and iptables to forward specific ports from VPN clients to a virtual machine's internal IP address.

Read More
Understanding Partitions in the 1980s: A Look Back at MS-DOS and Master Boot Record

Explains how the Master Boot Record and partition table enabled MS-DOS to manage multiple disk volumes on a single physical drive.

Read More
Windows 10 Enterprise: Keyboard Not Detected in Managed Organization with Admin Privileges

Resolve Windows 10 Enterprise keyboard detection failures caused by Group Policy restrictions, driver corruption, or USB enumeration errors.

Read More
Can't Find x86_64 Versions of Applications on MacOS arm64 (M1)

Resolve missing x86_64 app issues on M1 Macs by installing Rosetta 2 and reinstalling apps as universal binaries.

Read More
How to Hide Installation Source for an Android App

Manage Android app installation source visibility by using USB transfers or file managers to reduce browser traces and isolate data via work profiles.

Read More
Connecting Momentus 4200.2 ST9808210A Hard Drive via USB Cable

Resolve inability to access Seagate Momentus 4200.2 ST9808210A hard drive by connecting it via USB using a compatible SATA-to-USB adapter and configuring the disk in Windows.

Read More