Skip to content

Cron Jobs

Cron Jobs

If you have ever wished something on your server would just happen automatically — cleaning up old files, running a maintenance script, rotating logs — cron jobs are the answer. Instead of logging in manually or relying on WordPress to handle system-level work, you set a schedule once and FlyWP handles the rest.

Cron jobs page

A cron job (named after the Unix time-based job scheduler) is a command that your server runs automatically at intervals you define — every hour, once a day, every Sunday at 3 AM, or any other pattern. You define the command and the schedule; the server takes care of the rest.

Overview

The Crons tab on your server’s detail page shows all server-level cron jobs you have configured. If no cron jobs have been added yet, you will see an empty state message: “No cron jobs found.”

Adding a Cron Job

  1. Navigate to your server’s detail page and click the Crons tab.
  2. Click the Add Cron button.
  3. Enter the command you want to run (e.g., /usr/bin/find /tmp -type f -mtime +7 -delete).
  4. Set the schedule using cron syntax or a preset interval.
  5. Click Save.

FlyWP registers the cron job on your server, and it will begin running at the next scheduled time.

Common Use Cases

TaskExample CommandSuggested Schedule
Clean up temp filesfind /tmp -type f -mtime +7 -deleteDaily
Restart a servicedocker restart nginx-proxyWeekly
Run a custom script/home/fly/scripts/backup-cleanup.shDaily
Clear application logstruncate -s 0 /var/log/app/*.logWeekly

Cron Schedule Syntax

Cron schedules use five fields representing minute, hour, day of month, month, and day of week. Each field accepts a number, a wildcard (* means “every”), or a range.

* * * * *
| | | | |
| | | | +-- Day of week (0-7, where 0 and 7 are Sunday)
| | | +---- Month (1-12)
| | +------ Day of month (1-31)
| +-------- Hour (0-23)
+---------- Minute (0-59)

Common examples:

ScheduleCron Expression
Every minute* * * * *
Every hour0 * * * *
Every day at midnight0 0 * * *
Every Sunday at 3:00 AM0 3 * * 0
Every weekday at 9:00 AM0 9 * * 1-5

Managing Cron Jobs

Each cron job in the list gives you two actions:

  • Edit — update the command or change the schedule at any time.
  • Delete — remove the cron job entirely from the server.

Best Practices

  • Test your commands manually via SSH (Secure Shell, a way to connect to your server from a terminal) before scheduling them, to confirm they work as expected before automating.
  • Use absolute paths in your commands (e.g., /usr/bin/find instead of just find) to avoid PATH issues — the environment that runs cron jobs does not always have the same settings as your interactive shell.
  • Stagger schedules — avoid scheduling multiple resource-intensive tasks at the same time to prevent overloading your server.
  • Monitor your server resources on the Status tab after adding new cron jobs to confirm they are not causing unexpected load.