Setting Up Cronjob
Setting Up Cronjob
The platform supports cron-based automation for recurring tasks such as clearing logs, creating backups, and running application or database scripts.
Create an Environment
1Sign in to the dashboard
Log in to the platform dashboard.
2Create the environment
Click Create environment.
3Select the topology
Choose the required application server and database, for example Tomcat and MySQL. Enter the environment name and click Create.
The application-server and database nodes are created and displayed in the dashboard.
Upload the Script
Application Server
- Click Config for the application server.
- Upload the script to the appropriate location:
- Java server: upload it to the home folder.
- PHP server: upload it to the folder containing the application.
Database
- Click Config for the MySQL or MariaDB node.
- Upload the required script to the scripts folder.
Configure the Cron Scheduler
1Open the cron file
In the configuration panel, open the cron folder and then open the {nodeName} file.
Add the required cron commands to this file. Each entry must follow the standard six-field crontab format.
Crontab Format and Values
{minute} {hour} {day} {month} {day-of-week} {command-line-to-execute}
| Field | Allowed Values | Description |
|---|---|---|
minute | 0–59 | Minute when the job runs. |
hour | 0–23 | Hour in 24-hour format. |
day | 1–31 | Day of the month. |
month | 1–12 | Month of the year. |
day-of-week | 0–7 | Both 0 and 7 mean Sunday; 1 is Monday, 2 is Tuesday, and so on. |
command-line-to-execute | Full path | Absolute path to the command or script. |
- All fields must appear in the exact order, with no missing fields.
*represents every possible value for a field./defines an interval, for example every three hours.- Use commas for multiple values, for example
1,6,19. - Use a hyphen for a range, for example
8-17.
* in the hour field means every hour. A pattern such as */3 means every three units of that field.
Script Paths
Always specify the full path to the script.
| Node Type | Script Path |
|---|---|
| Tomcat / TomEE | /opt/tomcat/temp/{scriptName} |
| Jetty | /opt/jetty/home/{scriptName} |
| GlassFish | /opt/glassfish3/temp/{scriptName} |
| PHP application server | /var/www/webroot/{appFolder}/{scriptName} |
| MySQL / MariaDB | /var/lib/jelastic/bin/{scriptName} |
Cron Examples
To run a Tomcat script every minute:
*/1 * * * * /opt/tomcat/temp/test.sh
To run the same script through Bash:
*/1 * * * * /bin/bash /opt/tomcat/temp/test.sh
Built-In Interpreters
| Interpreter | Path |
|---|---|
| Bash | /bin/bash |
| Python | /usr/bin/python |
| Perl | /usr/bin/perl |
| SED | /bin/sed |
| AWK | /bin/awk |
| Expect | /usr/bin/expect |
| PHP | /usr/bin/php |
Save and Apply
- Make sure there is a blank line after the final cronjob entry.
- Save the cron file.
- The platform applies the updated schedule.
