How to Schedule Tasks With Webmin
If you’ve ever felt the urge to automate a repetitive server task but can’t find the right place in your control panel, this will show you how to schedule tasks with Webmin—no extra plugins, just the built‑in cron interface.
Setting Up the Cron Module
Before any magic happens, make sure the Cron module is enabled. Go to System => Software Packages, search for “cron” and install it if it’s missing. Once installed, head to Servers => Scheduled Tasks. Webmin will ask you to pick a user; picking root gives you full power but also means any mistake could bring the whole box down. If that scares you, choose a less privileged account instead.
Creating a New Scheduled Task
1. Click “Create a new scheduled task.”
2. In the Command field, paste exactly what you’d run from the shell—e.g., /usr/bin/php /var/www/html/cleanup.php.
3. For User, select the account that owns the script; if it’s a PHP file, pick the same user that runs your web server so permissions line up.
the command string is executed in a bare‑bones shell environment. If you leave out #!/usr/bin/php or the correct path, cron will silently fail and you’ll only notice when logs stop updating.
Choosing the Right Time Format
Webmin’s UI breaks down the usual minute, hour, day of month, month, and day of week fields.
- Use */5 in “Minute” if you want the job every five minutes.
- For daily at 3 a.m., set “Hour” to 3 and “Minute” to 0.
- If you only need it on weekdays, set “Day of week” to 1-5.
I’ve seen this happen after a bad driver update: the system clock drifted by an hour, so a job that was supposed to run at midnight started firing at 1 a.m. Checking the cron time format and syncing NTP fixes it.
Testing Your Script
Don’t trust the UI blindly. Run crontab -l on the target account to see what Webmin actually installed. Then, manually execute the command once outside of cron to confirm it works in that environment. If you’re using a virtual environment or custom PATH entries, add them inside the command itself:
/usr/bin/python3 /opt/scripts/myscript.py --env prod
Common Pitfalls
- Missing Permissions – Scripts owned by root but run as another user will hit “Permission denied.”
- Wrong Working Directory – If your script relies on relative paths, prepend cd /path/to/dir && to the command.
- No Output Redirected – Cron emails the output to the owner’s mailbox. If you want a log file, redirect stdout and stderr:
/usr/bin/php /var/www/html/backup.php >> /var/log/backup.log 2>&1
Clean Up Old Jobs
If you’re not sure whether a job is still needed, disable it first rather than deleting it outright. Webmin lets you toggle the “Enabled” checkbox; that way you can re‑enable without recreating everything.
That’s all there is to it. Once you’ve got a few cron jobs in place, your server starts feeling less like a maintenance nightmare and more like a well‑tuned machine.