welcome: please sign in

Diff for "MemberManual/UsingCron"

Differences between revisions 1 and 12 (spanning 11 versions)
Revision 1 as of 2007-10-28 00:39:39
Size: 698
Editor: MichaelOlson
Comment: Outline
Revision 12 as of 2013-07-22 21:38:54
Size: 2659
Editor: ClintonEbadi
Comment: remove references to mire, hyperlink to crontab man page, note how to remove
Deletions are marked like this. Additions are marked like this.
Line 5: Line 5:
[[TableOfContents]] <<TableOfContents>>
Line 9: Line 9:
It is very important that you read the [:MemberManual/RunningUnattendedCommands:Running Unattended Commands page] to understand the general idea of how to run unattended commands on Mire. It is very important that you read the [[MemberManual/RunningUnattendedCommands|Running Unattended Commands page]] to understand the general idea of how to run unattended commands.

= Requesting cron permissions =

Use [[https://members.hcoop.net/portal/sec|the security settings page]] of the portal to request permission to use cron. You won't be able to create a crontab before submitting a request and having it approved.
Line 13: Line 17:
Cron needs a special configuration file to tell it how to operate. Cron needs a special configuration file to tell it how to operate.  It is suggested that this file be called {{{~/.crontab}}}, though it can have any name.
Line 15: Line 19:
TODO: Describe format. Suggest calling this file {{{~/.crontab}}}. For an explanation of the format of this file, see the [[http://linux.die.net/man/1/crontab|crontab manual page]] (or run `man crontab` on the shell server).
Line 17: Line 21:
= Activating your cron configuration = = Managing your cron jobs =
Line 19: Line 23:
TODO: crontab ~/.crontab. == Activating your cron configuration ==
Line 21: Line 25:
= Exmaples = Once you are satisfied with your setup, run the following command to activate your changes, assuming that your configuration file is called {{{~/.crontab}}}:
Line 23: Line 27:
TODO: Give examples, based on example given near the end of MemberManual/RunningUnattendedCommands. {{{
crontab ~/.crontab
}}}

== Disabling your cron jobs ==

Just run `crontab -r ~/.crontab`

== Checking your cron configuration ==

Run `crontab -l` to display the jobs cron is running for you.

= Examples =

One convention for making scripts to run commands in their own PAG, as specified by the [[MemberManual/RunningUnattendedCommands|Running Unattended Commands page]], is to create the {{{~/scripts}}} directory, and place your scripts there. Then, make a cron configuration file that looks something like this.

{{{
PATH=/afs/hcoop.net/common/bin:/usr/local/bin:/usr/bin:/bin

09 0 * * 0 run-in-pagsh --fg clean-mail ~/scripts/clean-mail
11 0 * * 0 run-in-pagsh --fg remove-tmp ~/scripts/remove-tmp
12 0 * * 0 run-in-pagsh --fg weekly-comment-check ~/scripts/weekly-comment-check
*/10 * * * * run-in-pagsh --fg make-git-projects ~/scripts/make-git-projects
}}}

The PATH line is needed so that you have access to {{{run-in-pagsh}}}. Make sure you don't try to reference any other environment variables like {{{$HOME}}}, because cron will not expand them properly.

The first cron command runs something 9 minutes after midnight (aka the "0th" hour), every day of the month, every month, provided that it is Sunday (aka the "0th" day of the week). In short: run something at 12:09 every Sunday.

The second and third commands are similar.

The fourth command runs something every 10 minutes.
----
CategoryMemberManual

This page describes the basic use of cron on HCoop systems.

Prerequisites

It is very important that you read the Running Unattended Commands page to understand the general idea of how to run unattended commands.

Requesting cron permissions

Use the security settings page of the portal to request permission to use cron. You won't be able to create a crontab before submitting a request and having it approved.

Making a cron configuration file

Cron needs a special configuration file to tell it how to operate. It is suggested that this file be called ~/.crontab, though it can have any name.

For an explanation of the format of this file, see the crontab manual page (or run man crontab on the shell server).

Managing your cron jobs

Activating your cron configuration

Once you are satisfied with your setup, run the following command to activate your changes, assuming that your configuration file is called ~/.crontab:

crontab ~/.crontab

Disabling your cron jobs

Just run crontab -r ~/.crontab

Checking your cron configuration

Run crontab -l to display the jobs cron is running for you.

Examples

One convention for making scripts to run commands in their own PAG, as specified by the Running Unattended Commands page, is to create the ~/scripts directory, and place your scripts there. Then, make a cron configuration file that looks something like this.

PATH=/afs/hcoop.net/common/bin:/usr/local/bin:/usr/bin:/bin

09 0 * * 0   run-in-pagsh --fg clean-mail           ~/scripts/clean-mail
11 0 * * 0   run-in-pagsh --fg remove-tmp           ~/scripts/remove-tmp
12 0 * * 0   run-in-pagsh --fg weekly-comment-check ~/scripts/weekly-comment-check
*/10 * * * * run-in-pagsh --fg make-git-projects    ~/scripts/make-git-projects

The PATH line is needed so that you have access to run-in-pagsh. Make sure you don't try to reference any other environment variables like $HOME, because cron will not expand them properly.

The first cron command runs something 9 minutes after midnight (aka the "0th" hour), every day of the month, every month, provided that it is Sunday (aka the "0th" day of the week). In short: run something at 12:09 every Sunday.

The second and third commands are similar.

The fourth command runs something every 10 minutes.


CategoryMemberManual

MemberManual/UsingCron (last edited 2019-01-14 19:16:18 by ClintonEbadi)