Home › Cron Jobs in Webmin
How to Add a Cron Job in Webmin
Webmin's "Scheduled Cron Jobs" module gives you full control over every cron job on the server, for every user. This guide covers setup, running jobs as different users and the difference between Scheduled Cron Jobs and Scheduled Commands.
Scheduled Cron Jobs vs Scheduled Commands
Webmin has two separate modules that are easy to confuse. Make sure you use the right one. Full reference: Scheduled Cron Jobs - Webmin documentation.
| Module | Runs | Use for |
|---|---|---|
| Scheduled Cron Jobs | Repeatedly, on a recurring schedule | Backups, queue processing, regular tasks |
| Scheduled Commands | Once, at a specific date and time | One-time tasks, deferred commands (at jobs) |
Add a Cron Job in Webmin
1. Navigate to Scheduled Cron Jobs
Go to System › Scheduled Cron Jobs. The main page shows a list of all existing cron jobs on the server, including those created by the OS and other applications. Be careful not to edit or delete jobs you did not create.
2. Create a new job
Click Create a new scheduled cron job at the top or bottom of the list. In the form, set the user to run as, the command, and the schedule.
3. Set the schedule
In the "When to execute" section, for each field (Minutes, Hours, Days, Months, Weekdays) choose either "All" (equivalent to *) or "Selected" to pick specific values.
You can select multiple values per field - for example, select 0 and 30 in Minutes to run at :00 and :30.
4. Set the user and command
In "Execute cron job as", enter the Unix user you want to run the job as. In "Command to execute", enter the full command - always use absolute paths.
/usr/bin/php /var/www/html/script.php >> /var/log/myjob.log 2>&1
Output and Email Notifications
By default, Webmin's cron jobs send any output by email to the job owner. This is standard Linux cron behaviour.
To suppress emails for a job, redirect output to /dev/null or a log file:
Suppress all output (no email)
/path/to/script.sh > /dev/null 2>&1
Log output to file
/path/to/script.sh >> /var/log/myjob.log 2>&1
Run a job immediately from Webmin
On the job list, click the command for any job to open its edit page. From there, click Run now to execute it immediately and see the output in the browser. Useful for testing before waiting for the scheduled time.
Practical Examples
| Task | User | Expression | Command |
|---|---|---|---|
| Daily DB backup | root | 0 2 * * * |
/usr/bin/mysqldump -u root mydb > /backup/db.sql |
| Run PHP script | www-data | */15 * * * * |
/usr/bin/php /var/www/html/queue.php |
| Log rotation | root | 0 0 * * 0 |
/usr/sbin/logrotate /etc/logrotate.conf |
| Laravel scheduler | www-data | * * * * * |
/usr/bin/php /var/www/app/artisan schedule:run >> /dev/null 2>&1 |
Generate the cron expression for your Webmin job
Build the schedule visually, then use the "Selected" option for each field in Webmin's form - or paste the full expression if your Webmin version supports direct input.