Setting up Cronjob
This guide has been reviewed and reformatted for Ruk-Com Cloud PaaS. Screens may vary slightly by platform version.
Click or tap a screenshot to view it at its original size.
Objective
This guide explains how to use Setting up Cronjob on Ruk-Com Cloud PaaS, with ordered procedures and practical verification points.
Before you begin
- Sign in with an account permitted to manage the relevant environment.
- Confirm the target environment, region and resources before saving changes.
- Create a backup or rollback plan before changing a production system.
Cron is a command to run at a specified time in Unix-like computer operating systems. Cron allows users to schedule tasks (commands or shell scripts) to run periodically at certain times or days, typically used to automate maintenance or system administration. Although its general nature means it can be used for other purposes, such as connecting to the internet and downloading email.
Ruk-Com Cloud allows you to run your programs at a specified time with the help of cron. You can use this to work according to the given scenario:
- Clearing logs
- Backup
- Running the script
You can see an example below.
Creating the environment
1. Login to Ruk-Com Cloud Dashboard.
2. Click the buttonNew environment

3. On the environment topology page, select the application server and database that you want to use (such asTomcatandMySQL) Type the name of the environment and clickCreate

Uploading the script
1. Click the buttonConfigfor your server application

2. Upload the script you want to run to the following folder.
- home- If you use a Java server in your environment (as we example in this guide)
- The folder where your application is stored - if you are using a PHP server in your environment.

1. Click the buttonConfigFor databases (MySQL or MariaDB)

2. Upload the script you want to execute to the scripts folder.

Note:The script you want to execute should be an executable file. If not, you can use built-in language variables such as Bash, Perl, Python, SED, AWK, or Expect (depending on the script you use).
1. In the open configuration tab Go to the cron folder and open the {nodeName} file.

2. In this section you can write all the necessary commands to schedule your jobs, which should consist of a basic crontab definition format consisting of 6 fields and separated by spaces.
{minute} {hour} {day} {month} {day-of-week} {command-line-to-execute}
While specifying values, you must adhere to this standard:
- The fields must be in a certain order. with no blank or missing fields
- If necessary, you can use wildcards - "*" (asterisk) in the crontab file will denote every possible value for the field. For example, specifying "*" in the "Hour" field means"Run every hour"
- The "/" character is used to further define the frequency. For example, "*/3" in "hours" means "every three hours."
- For each parameter, you can specify multiple values, separated by commas. For example, if in "hours" you type "1,6,19", the task will run "at 1:00 a.m., at 6:00 a.m., and 19 hours". You can also specify a time period. For example, "8-17" means that the program will run. "Every hour from 8 to 17"
You should specify the full path to your script with the commandcronIt depends on the location of your script. The path can be any of the following:
- home folder for calculating Java nodes:
/opt/tomcat/temp/{scriptName} - Tomcat, TomEE
/opt/jetty/home/{scriptName} - Jetty
/opt/glassfish3/temp/{scriptName} - GlassFish
- Folder with application files and scripts for calculating PHP nodes:
/var/www/webroot/{appFolder}/{scriptName}
- Script folder for MySQL/MariaDB databases:
/var/lib/jelastic/bin/{scriptName}
3. For example, if your script is in your Tomcat home folder and you want it to be executed every minute. Your command line might look like this:
*/1 * * * * /opt/tomcat/temp/test.sh

Tips:If your script does not have an executable flag and you use a built-in interpreter such as Bash, Perl, Python, SED, AWK, or Expect (depending on your script), you should add the following path after setting the time for explicitly specifying the interpreter as a program:
- /bin/bash - for Bash
- /usr/bin/python - for Python
- /usr/bin/perl - for Perl
- /bin/sed - for SED
- /bin/awk - for AWK
- /usr/bin/expect - for Expect
- /usr/bin/php - for php-interpreter
In this case your command will be as follows:
*/1 * * * * /bin/bash /opt/tomcat/temp/test.sh

4. Please make sure there is a blank line after the last cronjob entry.
5. Save changes to apply settings.