CRON Documentation
INFO
The system allows you to declare "online" crons, meaning a cron job that connects to a remote server/s and executing tasks like the standart scheduler for Unix like operating systems.
┌───────────────────── minute (0 - 59)
│ ┌─────────────────── hour (0 - 23)
│ │ ┌───────────────── day of the month (1 - 31)
│ │ │ ┌─────────────── month (1 - 12)
│ │ │ │ ┌───────────── day of the week (1 - 7) (Sunday to Saturday, 0 is also Sunday)
│ │ │ │ │
│ │ │ │ │
│ │ │ │ │
* * * * * <command to execute>
The syntax of each line expects a cron expression made of five fields which represent the time to execute the command, followed by a shell command to execute.
Creating a cron job
Note that the design is a subject to change
You can create it through the API
From the main page go to the menu SSH -> CRON and you will see something like the image below Then click on the green button "Create" and this page will open up
Fields
Active
- it will stop the cronjob execution once deactivatedStore output
- store the output of the command execution to the disk, it's essential when wanting to send the data through email or reading from the APIStop remote script on timeout
- after given timeout it will stop the remote script. When turned off it will act as anohup
and the script wont be stopped even after timeoutSend Email only on error
- it will send only an email when the command fails ( exits with code > 0 )Execution timeout seconds
- after how much seconds the command will timeout and optionally it will be killed. DEFAULT 60Connect retry count
- retries ssh server connection if fails. The wait time between retries is incremental, so for example on the 5th try it will wait 5 seconds before the next attempt DEFAULT 5Name
- used only for information and it will be used for the notification emails REQUIREDSSH remote user
- use specific user, usefull when we have a wildcard server user defined and we want to connect. In most cases it will be empty, as the default server user will be used when definedSSH remote port
- overwrite the remote ssh portEmail output to
- add additional email where the output/error will be sendAPI token
- auto generated API key, that can be used as a view only token to access this cronjob output only through the APICommand input STDIN
- send a text to the command input STDIN. Usefull to pass sensitive data etc. Note that it's good practice to use it along with the fieldStop remote script on timeout
as the exeecution will hang if the command doesn't read the STDIN inputCron
- the cron expression to use. REQUIRED field. IT supports extended syntax to allow using the combination of weekday and day of month - for example you can use friday 13th
Examples
Clears the Apache error log at one minute past midnight (00:01) every day
1 0 * * * printf "" > /var/log/apache/error_log
Runs a shell script at 23:45 (11:45 PM) every Saturday
45 23 * * 6 /home/flux/scripts/export.sh
Every 5th minute of every first, second and third hour (i.e., 01:00, 01:05, 01:10, up until 03:55)
*/5 1,2,3 * * * echo hello world
Every 5th minute ( starting from 30th minute ) every 2 hours (i.e., 00:30, 00:35...01:30, up until 22:55)
30/5 */2 * * * echo hello world
Once a month at 00::01 on the first day of the month
1 0 1 * * echo hello world
Once a year at 00::01 on the 24th December
1 0 24 12 * echo hello world
Every minute for the first hour starting at 00:01 up until 00:55 on the 24th December
* 0 24 12 * echo hello world
Caveats
- When hovering over the
i
icons addiotional information will be provided about given field - When the field
Email output to
is omitted the global "alert" emails will be used instead - Email with error will be always sent when the cronjob fails to connect to a given server
- The percent sign (%) is not treated as special character, that denotes new line and the start of STDERR input, instead you should use the field 'Command input STDIN'