Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Excerpt
hiddentrue

In this section you can find sample implementations to deploy Cron servers. 

Cron job deployment via install.sh (bash)

  • 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 install.sh (adjustment necessary)

Code Block
languagebash
#!/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.'

Related

Tutorials

tutorials

Filter by label (Content by label)
showLabelsfalse
max10
sorttitle
showSpacefalse
cqllabel in ( "deployment" , "application" , "cron" ) and ancestor = "2014352487" and space = currentSpace ( )

Related

Components

components

Filter by label (Content by label)
showLabelsfalse
max10
sorttitle
showSpacefalse
cqllabel in ( "deployment" , "cron" , "application" ) and ancestor = "2014350220" and space = currentSpace ( )

Status
colourYellow
titleintermediate

Table of Contents
exclude(Related * | Recommended * |Table of contents).*


Filter by label (Content by label)
showLabelsfalse
max10
sorttitle
showSpacefalse
titleRelated questions
cqllabel in ( "deployment" , "application" , "cron" ) and ancestor = "2014351598" and space = currentSpace ( )