Cron is the time-based job scheduler in Unix-like computer operating systems. Cron enables users to schedule jobs (commands or shell scripts) to run periodically at certain times or dates. It is commonly used to automate system maintenance or administration, though its general-purpose nature means that it can be used for other purposes, such as connecting to the Internet and downloading emails.
The platform gives you a possibility to run your programs at specified time with a help of cron, which receives your instructions and performs any tasks following the derived scenarios. You can use this opportunity to perform periodic tasks, e.g.:
Log into the platform dashboard.
Click Create environment.
In a minute your environment with both Tomcat and MySQL nodes will be created.
Note: Script you want to perform should be an executable file. If it isn’t, you can use built-in interpreters, such as Bash, Perl, Python, SED, AWK, or Expect (depending on the script you use).
{minute} {hour} {day} {month} {day-of-week} {command-line-to-execute}
Field | Range of values |
---|---|
minute | 0-59 |
hour | 0- 23 |
day | 1-31 |
month | 1-12 |
day-of-week | 0-7 (where both 0 and 7 mean Sun, 1 = Mon, 2 = Tue, etc.) |
command-line-to-execute | the path to the program you want to run |
While stating these values you need to follow the next standards:
Pay attention that you should specify a full path to your script in the cron command. Depending on the location of your script the path can be as one of the following:
- home folder for Java compute nodes:
- /opt/tomcat/temp/{scriptName} - Tomcat, TomEE
- /opt/jetty/home/{scriptName} - Jetty
- /opt/glassfish3/temp/{scriptName} - GlassFish
- folder with your application files & scripts for PHP compute nodes:
- /var/www/webroot/{appFolder}/{scriptName}
- scripts folder for MySQL/MariaDB databases:
- /var/lib/jelastic/bin/{scriptName}
/1 * /opt/tomcat/temp/test.sh
Tip: If your script does not have executable flag and you use built-in interpreters, such as Bash, Perl, Python, SED, AWK or Expect (depending on your script), you should add the following paths after time settings for explicit specifing the interpreter:
- /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 following:
/1 * /bin/bash /opt/tomcat/temp/test.sh
That’s all. As you can see, it is pretty easy to schedule your tasks with the platform. Enjoy!