Live stream set for 2025-05-15 at 14:00:00 Eastern
Ask questions in the live chat about any programming or lifestyle topic.
This livestream will be on YouTube or you can watch below.
Job Scheduler
Cron jobs are scheduled tasks that run automatically on a periodic basis on POSIX-compliant systems.
Cron jobs automate repetitive tasks such as backups, updates and system maintenance.
The command crontab
is a job scheduler.
The focus of this tutorial will be on creating a custom script in PHP to demonstrate automation.
- Create a list of form fields.
- Choose command line scripting language such as Bash or PHP.
- Create a script to fill in form fields and submit destination.
- Manually run the script.
- Set up a cronjob to automate the script at the desired interval.
Requirements For cURL
Glossary:
POSIX
Portable Operating System Interface family of standards for maintaining compatibility between operating systems.
Job
A unit of work or unit of execution (that performs said work).
Task
A unit of execution or a unit of work.
Job Scheduler
Application for controlling unattended background program execution of jobs.
Batch Scheduling
Method of running software programs called jobs in batches automatically.
Crontab
Cron Table, configuration file that specifies shell commands to run.
Tools
Name | Description | Example |
---|---|---|
Text editor | For creating and editing source code | Apache Netbeans IDE |
SSH | Secure Shell Client | OpenSSH |
Shell Access | Access to the command line. | Terminal |
Name | Description | Example |
Common Syntax For Crontab
Name | Description | Example |
---|---|---|
Every Minute | Every Weekday, Every Month, Every Day, Every Hour, Every Minute | * * * * * /path-to-bash-script |
Every Five Minutes | Every Weekday, Every Month, Every Day, Every Hour, Every Five Minutes | */5 * * * * /path-to-bash-script |
Every Hour | Every Weekday, Every Month, Every Day, Every Hour, Specified Minute | 0 * * * * /path-to-bash-script |
Every Day | Every Weekday, Every Month, Every Day, Specified Hour, Specified Minute | 0 0 * * * /path-to-bash-script |
Every Week | Specified Weekday, Every Month, Every Day, Specified Hour, Specified Minute | 0 0 * * 0 /path-to-bash-script |
Every Month | Every Weekday, Every Month, Specified Day, Specified Hour, Specified Minute | 0 0 1 * * /path-to-bash-script |
Twice A Month | Every Weekday, Every Month, Specified Days, Specified Hour, Specified Minute | 0 0 1,15 * * /path-to-bash-script |
Twice A Month | Every Weekday, Every Month, Specified Days, Specified Hour, Specified Minute | 0 0 1,15 * * /path-to-bash-script |
Every Year | Every Weekday, Specified Month, Specified Day, Specified Hour, Specified Minute | 0 0 1 1 * /path-to-bash-script |
Name | Description | Example |
Cron Jobs
# Every Minute # * * * * * /path-to-bash-script # Every Five Minutes # */5 * * * * /path-to-bash-script # Every Start Of The Hour # 0 * * * * /path-to-bash-script # Every Day At Midnight # 0 0 * * * /path-to-bash-script # Every Week On Sunday At Midnight # 0 0 * * 0 /path-to-bash-script # Every Month On First Day At Midnight # 0 0 1 * * /path-to-bash-script # Every Month On First Day And 15th At Midnight # 0 0 1,15 * * /path-to-bash-script # Every Year On First Month And First Day # 0 0 1 1 * /path-to-bash-script
Explanation:
- Cron tables are started with the
crontab
command. - Each cron job is of the format MIN HOUR DOM MON DOW CMD.
- The CMD (Command) represents the actual command or script to be run.
The code for commands is not provided in this tutorial because it is unique for specific needs. Testing cron jobs using crontab
is easily performed by testing the command or script prior to creation.

Usage
You can run crontab
on the command-line, or integrated into an application as an extension. For this tutorial, crontab
was used to create cron jobs. The command line tool was made available by installing Cronie which can be downloaded from Cronie cron daemon project. PHP scripting language can be downloaded from PHP. Then the downloaded file is extracted directly on the server or locally before individual files are uploaded if applicable.
Open Source
Cronie is licensed under the GNU General Public License Version 2.0. The copyleft license comes with strict rules and requirements to ensure the software remains free and open-source. It allows commercial use, modification, distribution, and allows making derivatives proprietary, consult the license for more specific details.
The PHP scripting language is licensed under the PHP License. The permissive license has conditions requiring preservation of copyright and license notices. Redistribution is permitted in source or binary form with or without modifications, consult the license for more specific details.
Conclusion:
Crontab is used for task scheduling and task automation using the command line tool crontab
. The scheduled cron jobs can either be commands or scripts
If you enjoy this article, consider supporting me by purchasing one of my WordPress Ojambo.com Plugins or programming OjamboShop.com Online Courses or publications at Edward Ojambo Programming Books or become a donor here Ojambo.com Donate
References:
- Customer Sets Price Plugin for WooCommerce on Ojambo.com
- Learning JavaScript Course on OjamboShop.com
- Learning Python Course on OjamboShop.com
- Learning PHP Course on OjamboShop.com
- Learning JavaScript Paperback on Amazon
- Learning JavaScript Ebook on Amazon
- Learning Python Ebook on Amazon
- Learning PHP Ebook on Amazon
- OjamboServices.com For Custom Websites, Applications & Tutorials