Home‎ > ‎Documentation‎ > ‎

Cron Jobs

The following is an example of how to set up shell scripts and cron jobs.

Job Processor
    The job processor script calls the jobProcesor.php url which in turn executes the Job Processor logic.
        ~/jobProcessor.sh 
        ---
        curl localhost/wptmonitor/jobProcessor.php?key=<jobProcessorKey>
        ---
        Replace <jobProcessorKey> with the key entered during the installation process.

EC2 Processor ( Optional )
    Create the following shell script if using the Amazon EC2 auto scaling feature.
     ~/ec2Processor.sh
        ---
        curl localhost/wptmonitor/ec2Processor.php?key=<jobProcessorKey>
        ---
        Replace <jobProcessorKey> with the key entered during the installation process.

Job Processor Log zipping script
    The following simply overwrites a gzip'd version of the jobProcessor_html.log file at the scheduled interval. This example is based on the default installation location.
    User: ec2-user
    Script Name: gzipJobProcessorLog.sh
    Shell Script location: /home/ec2-user/cron_jobs/gzipJobProcessorLog.sh
    Set to run weekly: sudo ln -s /home/ec2-user/cron_jobs/gzipJobProcessorLog.sh /etc/cron.weekly/.
    Script Contents: 
        ---
        cd /var/www/html/wptmonitor/
        gzip --force jobProcessor_log.html
        ---

Creating the crontab entries
    For jobProcessor and ec2Processor no elevated permissions are required. The following is an example of the settings when executing crontab -e as the default user.

    crontab -e

    */5 * * * * ~/cron_jobs/jobProcessor.sh
    */15 * * * * ~/cron_jobs/ec2Processor.sh

    In this example the Job Processor runs every 5 minutes and the EC2 Processor every 15 minutes.
    

    

Comments