=encoding utf8 =head1 NAME whenjobs - A powerful but simple cron replacement =head1 SYNOPSIS Editing the jobs script: whenjobs -e | --edit whenjobs -l | --list Get and set variables: whenjobs --get variable whenjobs --set variable value [--type bool|int|float|string] whenjobs --variables Start and stop the per-user daemon: whenjobs --daemon-start whenjobs --daemon-stop whenjobs --daemon-status whenjobs --daemon-restart =head1 DESCRIPTION Whenjobs is a powerful but simple replacement for cron. It lets you run jobs periodically like cron, but it also lets you trigger jobs to run when user-defined variables are set or change value. Periodic jobs are written like this: every 10 minutes : << # Get the current load average. load=`awk '{print $1}' /proc/loadavg` whenjobs --set load $load --type float >> When-statements let you create jobs that run based on variables set elsewhere: when load >= 6 : << mail -s "ALERT: high load average: $load" $LOGNAME < /dev/null >> (When statements are "edge-triggered", meaning that this job will only run when the load goes from under 6 to E 6). Like L, whenjobs are controlled by a jobs file which can be edited from the command line: $ whenjobs -e Whenjobs uses a daemon called L. Unlike crond, this daemon runs as the same user. Each user who wants to use whenjobs starts their own daemon: $ whenjobs --daemon-start You can also have the daemon start as you when the machine boots by adding the following line to a boot file such as C. Replace C with your username: su username -c /usr/sbin/whenjobsd Variables are the key to expressing dependencies between whenjobs. Variables are stored (per-user) in the daemon. You can use the command line tool to examine and set variables: $ whenjobs --variables load=0.9 $ whenjobs --set cat sushi $ whenjobs --get cat sushi The act of setting a variable (using I<--set>) can trigger jobs to run. =head1 OPTIONS =over 4 =item B<--daemon-start> =item B<--daemon-stop> Start and stop the per-user daemon. =item B<--daemon-status> Prints the status of the daemon: C or C. =item B<--daemon-restart> Restart the daemon. (If it is not running, then this command starts it). =item B<-e> =item B<--edit> Edit the jobs script. If you make changes to the jobs script, then it is automatically uploaded to the daemon. The C<$EDITOR> environment variable is used for editing. If not set, C is used. =item B<--get> variable Print the value of a variable. =item B<-l> =item B<--list> List the jobs script. =item B<--lib> directory Set the library directory which needs to contain the auxiliary files C and C. Normally you do not need to specify this. However if you are running whenjobs without installing it, then you need to point this to the C directory from the source, eg: whenjobs --lib $builddir/lib -e =item B<--set> variable value =item B<--type> bool|int|float|string I<--set> sets the variable named C to the new C. The variable is created if it does not already exist. Note that setting a variable can cause jobs to run immediately. To unset a variable, set it to the empty string: whenjobs --set var "" By default variables are untyped (more precisely, they are treated as strings). You can also set the type of a variable when setting it by adding the optional I<--type> parameter: whenjobs --set free_space 10000 --type int See the discussion of variable types in the L section below. =item B<--upload> Compile the jobs script and upload it to the daemon, without editing. Note that the I<--edit> option does this automatically. Furthermore, when the daemon is started it checks for a jobs script and loads it if found. =item B<--variables> Display all the variables and their values, in the format C. =item B<-V> =item B<--version> Display the name and version of the program and exit. =item B<-help> =item B<--help> Display brief usage and exit. =back =head1 REFERENCE =head1 FILES =head1 ENVIRONMENT VARIABLES =head1 SEE ALSO L =head1 AUTHOR Richard W.M. Jones L =head1 COPYRIGHT Copyright (C) 2012 Red Hat Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.