-
Notifications
You must be signed in to change notification settings - Fork 1
Scheduled Processes
Procodile supports scheduled processes alongside normal long-running processes.
Scheduled processes are for jobs that run on a schedule instead of staying up continuously.
You can define a scheduled process in either of two ways.
Use __AT__ between the process name and a cron expression:
"cleanup__AT__*/10 * * * * *": bundle exec rake cleanupRules:
-
__AT__must use an uppercaseAT, with exactly two underscores on each side. - The cron expression uses the traditional five-field crontab format, with optional support for a leading sixth field for seconds.
- second (optional)
- minute
- hour
- day
- month
- weekday
processes:
cleanup:
at: "*/10 * * * * *"This is equivalent to the Procfile example above.
If both the Procfile and the options files define a schedule for the same process, the options files take precedence.
It's often a good idea to use a cron_ prefix in the process name for this case, for example cron_cleanup.
This makes it easier to recognize the entry as a scheduled job rather than a normal long-running service.
Scheduled processes behave differently from normal daemon-style processes.
Each run creates a process, waits for it to finish, records the result, and then removes that instance.
procodile start enables the schedule. It does not execute the job immediately.
procodile restart -p job reloads and re-enables the schedule. It does not execute the job immediately.
If you change a schedule and run:
procodile reloadthe new schedule becomes active immediately.
Procodile also supports random_delay for scheduled processes in the options files. The value is in seconds and only delays execution forward.
For example:
processes:
cleanup:
at: "*/10 * * * * *"
random_delay: 600This is roughly equivalent to wrapping the command with something like sleep $((RANDOM % 600)) before running the real work.
If you want to do it manually, the simplest approach is to wrap the command yourself.
For example:
"cleanup__AT__*/10 * * * * *": bash -lc 'sleep $((RANDOM % 600)); exec bundle exec rake cleanup'This keeps the schedule itself unchanged, but delays the actual work by a random number of seconds.
This approach depends on bash because $RANDOM is a Bash feature.
Procodile does not allow overlapping runs of the same scheduled process.
If a previous run is still active when the next scheduled time arrives:
- the new run is skipped
- the current run continues
If this happens repeatedly, Procodile raises a runtime issue so it is visible in CLI output and status.
For scheduled processes:
-
jobrefers to the scheduled task itself. -
job.3refers to a specific currently running instance, You can get the instance name from procodile status.
Stopping the scheduled task itself only disables future runs.
procodile stop -p jobStopping a scheduled instance also disables future scheduling for that job.
procodile stop -p job.3procodile restart -p cleanupThis reloads the schedule and re-enables it. It does not force an immediate run.
If you want to restart only a currently running scheduled instance, target that instance explicitly:
procodile restart -p cleanup.3This restarts that running instance and, if future scheduling was previously disabled, re-enables it.
Scheduled processes display schedule-specific status:
ScheduleLast Started AtLast Finished AtLast Exit StatusLast Run Duration-
Random Delaywhen configured, shown as the maximum delay
They do not display daemon-only fields such as quantity or restart mode.
If the cron expression is invalid, Procodile records a runtime issue and explains the expected format.
Example:
Scheduled process 'cleanup' has invalid cron schedule '...'
After fixing the schedule, run either:
procodile reloador:
procodile restart -p cleanupto restore it.