Warning |
---|
You have tried to access an archived page. Please go to the new https://root360.atlassian.net/wiki/spaces/KB to find more documents. |
...
In this section you can find sample implementations to deploy Cron servers.
It will be added to each brief assistance to Design Decisions, a process and a sample implementation (customization required) pointed out.
Table of Contents |
---|
Bash Cron Job Deployment
Why bash?
It is usually available,
easy to understand and
stable
process
Caveat: definition of Cron in the script or config depending on the environment
Decide is what to do according to set environment variables
Write the crontab
Cleanup temporary files
Deployment
The bash script is expected by the configuration management system under a specific path and
called parameterized plain or by appointment
When it comes to the server by a cron server (ROLES contains "cron") is written a defined crontab
This also assumes that the Cron to be run, are actually stored in the specified directory and executable.
Example (adjustment necessary)
Code Block | ||||
---|---|---|---|---|
| ||||
#!/bin/bash if [ -z "$ROLES" ]; then echo 'Roles not set!' exit 1 fi # Main if [ "$ROLES" = "cron" ]; then # write crontab file echo '#Cron by install.sh' > tempfile echo '00 09 * * 1-5 echo hello' >> tempfile echo '00 15 * * * echo bla' >> tempfile # cron example with custom logging echo "* * * * * date >> /var/log/application/cron.log && cd /var/www/ && /usr/bin/php cron.php >> /var/log/application/cron.log 2>&1" >> tempfile # Update crontab crontab tempfile # Clean Up rm tempfile fi echo 'Done successfully.' |
...