Category: How to: Manage Scheduled Tasks Using Cron in NodeWorx

Share this post...Tweet about this on TwitterShare on Google+0Share on Facebook0

InterWorx allows the NodeWorx administrator the ability to control the system’s crontabs without using command line. The NodeWorx administrator is able to do so for every *nix user on the system from the NodeWorx interface. Theiworx system user has some special cron jobs for the control panel too which perform many important, necessary actions throughout the day to keep the control panel running smoothly.

How to: view a system user’s crontab file

  1. Click the Server menu item if it is not already open.
  2. Click the CRON menu item.
  3. Locate the User: drop-down menu.
  4. In the User: drop-down menu, select the user whose crontab you would like to view. For example, to see the iworx user’s crontab, choose iworx in the drop-down menu.
  5. You will now see the chosen user’s crontab in the fields below.
  6. From here you may choose to add new CRON jobs, edit or delete existing CRON jobs, or edit CRON variables.

How to: Manage a system user’s crontab options

  1. Click the Server menu item if it is not already open.
  2. Click the CRON menu item.
  3. Choose the user whose crontab you would like to edit from the User: drop-down menu.
  4. You will now see the chosen user’s crontab, and the various CRON options, in the fields below.
  5. Change the option(s) you wish to update to the desired value(s).
  6. Click the  button.

CRON OPTIONS REFERENCE

Shell 
Choose the desired shell from the dropdown menu. All scripts will be executed with this shell. The default shell is /bin/sh.

PATH 
The PATH CRON option is similar to setting the shell PATH environment variable. Setting the PATH CRON option sets the directories which will be used in the search path for CRON.

MAILTO 
If an email address is provided here, any output produced by a cronjob will be emailed to this address.


How to: Set a cron job

  1. Click the Server menu item if it is not already open.
  2. Click the CRON menu item.
  3. Choose which user you will add the CRON job to.
  4. Choose either Simple Interface (the default) or Advanced Interface from the CRON Editor: drop-down menu.

PROCEDURE – SIMPLE INTERFACE

  1. Set the Minute interval. You can either set it to a specific minute (e.g. 8 is the 8th minute of every hour), or some interval (every 2, 5, 10, or 15th minute), or All for every minute.
  2. Set the Hour interval. You can either set it to a specific hour (e.g. 10PM is every day at 10PM), or some interval (every 2, 4, or 6th hour), or All for every hour.
  3. Set the Day interval. You can either set it to a specific day (e.g. 12 is the 12th day of every month), or All for every day.
  4. Set the Month interval. You can either set it to a specific month (e.g. Feb is every February), or All for every month.
  5. Set the Day of Week interval. You can either set it to a specific day of the week (e.g. Wed is every Wednesday), or All for every day of the week.
  6. Set the Script command you would like to run.
  7. Click the  button to add the CRON job.
You can select multiple values for any of the intervals. For example, you can hold the CTRL key and click “Sun” and “Tue” to select both Sundays and Tuesdays.

PROCEDURE – ADVANCED INTERFACE

  1. Set the Minute interval. You can either set it to a specific minute between 0 and 59 (e.g. 8 is the 8th minute of every hour), some range (e.g. 5-10 is minutes 5 through 10), * for every minute, or some interval (e.g. */10 is every 10 minutes).
  2. Set the Hour interval. You can either set it to a specific hour between 0 and 23 (e.g. 22 is every day at 10PM), some range (e.g. 5-10 is hours 5AM through 10AM), * for every hour, or some interval (e.g. */7 is every 7 hours).
  3. Set the Day interval. You can either set it to a specific day between 1 and 31 (e.g. 12 is the 12th day of every month), some range (e.g. 1-15 is days 1 through 15), * for every day, or some interval (*/3 is every 3 days).
  4. Set the Month interval. You can either set it to a specific month between 1 and 12 (e.g. 3 is every February), some range (e.g. 5-7 is months May through July), * for every month, or some interval (e.g. */2 is every two months).
  5. Set the Day of Week interval. You can either set it to a specific day of the week between 0 and 7 (e.g. 4 is every Thursday), * for every day of the week, some range (e.g. 1-4 is days Monday through Wednesday), or some interval (*/2 is every 2 days of the week). Note that both 0 and 7 represent Sunday.
  6. Set the Script command you would like to run.
  7. Click the  button to add the CRON job.
You can also do multiple values for any of the intervals by using commas to separate them. For example, to do every 7th, 11th, and 14th minute and every 30 minutes you can use 7,11,14,*/30 for the Minute interval.

EXAMPLES

The following are a few CRON examples, and how to set them up in both interfaces.

Example 1: Every 5 Minutes

Run every 5 minutes.

Simple Interface

Minute Hour Day Month Day of Week
Every 5 All All All All

Advanced Interface

Minute Hour Day Month Day of Week
*/5 * * * *

Example 2: Yearly

Run yearly (at exactly midnight on January 1st).

Simple Interface

Minute Hour Day Month Day of Week
0 Midnight 1 Jan All

Advanced Interface

Minute Hour Day Month Day of Week
0 0 1 1 *

Example 3: Monthly

Run monthly (at 2:15AM on the 5th of each month).

Simple Interface

Minute Hour Day Month Day of Week
15 2AM 5 All All

Advanced Interface

Minute Hour Day Month Day of Week
15 2 5 * *

Example 4: Weekly

Run weekly (at 4:32PM on every Thursday).

Simple Interface

Minute Hour Day Month Day of Week
32 4PM All All Thu

Advanced Interface

Minute Hour Day Month Day of Week
32 16 * * 4

Example 5: Daily

Run daily (at 12:45AM every day).

Simple Interface

Minute Hour Day Month Day of Week
45 Midnight All All All

Advanced Interface

Minute Hour Day Month Day of Week
45 0 * * *

Example 6: Hourly

Run hourly (at 24 minutes past the hour).

Simple Interface

Minute Hour Day Month Day of Week
24 All All All All

Advanced Interface

Minute Hour Day Month Day of Week
24 * * * *

Example 7 – Complex 1

Run 52 minutes after the hour every 4 hours (e.g. 12:52AM, 4:52AM, 8:52AM, etc…).

Simple Interface

Minute Hour Day Month Day of Week
52 Every 4 All All All

Advanced Interface

Minute Hour Day Month Day of Week
52 */4 * * *

Example 8 – Complex 2

Run 8, 22, and 47 minutes after the hour at 2AM and 2PM (e.g. 2:08AM, 2:22AM, 2:47AM, 2:08PM, 2:22PM, 2:47PM) of every third month.

Simple Interface

Minute Hour Day Month Day of Week
8, 22, 47 2AM, 2PM All Jan, Apr, Aug, Dec All

Advanced Interface

Minute Hour Day Month Day of Week
8,22,47 2,14 * */3 *

How to: Edit a Cron Job

  1. Click the Server menu item if it is not already open.
  2. Click the CRON menu item.
  3. Choose which user’s crontab you would like to edit.
  4. Click the [ Edit ] link next to the CRON job you would like to edit.
  5. Edit the CRON job.
  6. Click the  button to update the CRON job.

How to: Delete a Cron Job

  1. Click the Server menu item if it is not already open.
  2. Click the CRON menu item.
  3. Choose the user whose crontab you would like to edit from the User: dropdown menu.
  4. You will now see the chosen user’s crontab in the fields below, with a checkbox next to each cronjob.
  5. Mark the checkboxes next to the cronjobs you would like to delete. You may also click the [ Check All ] link at the bottom of the list to quickly check all the cronjobs.
  6. In the dropdown labeled with selected:, choose the Delete option.

InterWorx-specific cronjobs

The InterWorx cron jobs are extremely critical to the InterWorx control panel system. They manage disk and bandwidth quota enforcement, detect potential issues for your servers, compile stats, keep the license synchronized, etc. Without them, InterWorx would not function properly.

OVERVIEW:

The following cron process are run by the iworx system user and should not be deleted or edited unless there is a specific reason to do so.
The InterWorx crons are located at ~iworx/cron

iworx.pex –fively 

fively – rrd graphs updated, dns exported, and if in the iworx.ini has runtime=fively (the default) it does bandwidth and storage calculations too. Runs every 5 minutes.

iworx.pex –fifteenly
fifteenly – bandwidth and storage if the iworx.ini has runtime=fifteenly. Runs every 15 minutes.

iworx.pex –hourly
hourly – bandwidth and storage if the iworx.ini has runtime=hourly. Runs every hour.

iworx.pex –quad_daily

quad_daily – license.sync, and bandwidth and storage if the iworx.ini has runtime=quad_daily. Runs 4 times a day (every 6 hours).

iworx.pex –daily 
daily – OS update, bayes training, and bandwidth and storage if the iworx.ini has runtime=daily

Specifically:

  • Checks for OS and InterWorx Updates.
  • stats – runs through all domains and and enabled stats programs, and rotates the logs upon completion.
  • spamassassin training – uses “sa-learn” to train messages in users’ Learn Spam / Learn Ham folders.

iworx.pex –weekly 
Currently not used.

iworx.pex –monthly
Currently not used.

CRON
Nov 29, 2012, 3:20 pmBy: InterWorx
How to: Manage Scheduled Tasks Using Cron in NodeWorx
0 votes, 0.00 avg. rating (0% score)
(2) Comments
  1. Kevan Schwitzer: Hi. Quick question re the cron functionality. When setting up a new cron, how is it determined which node the cron will run on? Can this be chosen by the control panel user? Is the node that runs the cron, a random node? Thanks. Kevan
    September 4, 2013 at 11:00 am
    Reply
    • interworx: Thanks for the question! InterWorx system crons are propagated and run on all nodes. However, user-created crons are run only on the system they're setup on. If a cron is made through a SiteWorx account, it is run on the CM.
      September 5, 2013 at 1:24 pm
      Reply

Leave a Reply
Surround code blocks with <pre>code</pre>

Your email address will not be published.

Comments

Broken Link