Skip to content Skip to site navigation

Scheduling Commands and Scripts

Overview

The scheduling service allows you to run commands or scripts at specified intervals. The scripts are stored in AFS. The commands are called “cron jobs,” and they're useful for a variety of purposes such as rebuilding a search index hourly, updating a web site daily, or running monthly reports on databases. You can use the scheduling service tool to create new jobs or edit existing ones.

  • Flexible schedule: schedule jobs through an easy-to-use web interface.
  • Dedicated servers: run your specified jobs from a pool of dedicated servers. You don't have to run your own server for cron jobs or use any other UNIX machine where updates and reboots can affect scheduled jobs.
  • Shared administration: run jobs as a CGI principal (jdoe.cgi), a cron principal (jdoe.cron), or a group or department's CGI principal (dept-example.cgi — this allows other members of that group to administer the settings).

Run administrative tasks automatically

The admin for a Drupal website must run some tasks regularly: for example, update the index search, trim the logs, and check for security updates. Drupal provides a web page that will run these tasks for you, but it requires regular visits to this page every day (or every hour).

Instead, you can use the scheduling service to perform these tasks. Use the web page provided by Drupal to run these tasks — known as “cron.php” — and a UNIX program called “curl” that can request web pages from the command line. Then use the service to schedule a job that uses curl to request cron.php at regular intervals with the following command:

curl -sS https://www.stanford.edu/dept/example/cgi-bin/drupal/cron.php

The two flags (-sS) tell curl to be silent unless there are errors.

Set Access Control Lists (ACLs)

If you are using the scheduling service to run a script, it is important to assign the appropriate Access Control List (ACL) in the script's parent directory so that the CGI principal can run the script. (If you're unsure of what ACLs are and what they do, see the Setting Permissions with UNIX page for more information.)

For example, if you are running a script as group-foo/cgi
at
/afs/ir/group/foo/cgi-bin/tools/foo.sh

then you can fix the permissions problems by assigning the rlidwk ACLs (read, lookup, insert, delete, write, and lock permissions) to the group-foo.cgi file in the directory /afs/ir/group/foo/cgi-bin/tools.

Run the following command from anywhere you have access to AFS ACLs and press Enter:

fs sa /afs/ir/group/foo/cgi-bin/tools group-foo.cgi rlidwk

The directory permissions are reset and the cron job errors should stop.

Get started

To get started, first determine what command or script in AFS you'd like to run and then visit the scheduler's web interface at https://www-scheduler.stanford.edu.

Last modified March 15, 2024