|
Personal tools |
|
|
/User Guide/uschedule
From AnnvixScheduling jobs with uschedule Annvix uses the uschedule suite of programs to handle periodic task scheduling, similar to what at would do. According to the uschedule website, uschedule is not cron and uschedule is not at - it does offer similar functionality, but is not intended to be a drop-in replacement. It works differently. It’s designed to be different. Indeed, uschedule is quite different so here is a quick primer on how to use uschedule on Annvix.
BackgroundThe reason uschedule is used in Annvix as opposed to at is quite simple. With at, the user-space scheduling tool had to be suid root in order to allow users access to create their own jobs. Likewise, access control was goverened by the /etc/at.allow and /etc/at.deny files. uschedule, on the other hand, is never run by root. Each user can have their own uschedule daemon, which is run as that user, and only executes commands as that user. root is never involved except to initially setup the uschedule service. This means that we don't have to ever worry about using access controls to add or remove users from being able to schedule their own jobs. Likewise, users have full control over seeing how their jobs are handled by being able to observe logfiles. If a user should no longer be using uschedule, the service is simply stopped and/or removed. To give a user the ability to use uschedule, root must create the service for them. Setting up uscheduleTo give user 'joe' his own uschedule daemon, root must execute: # uscheduleconf /var/service/schedule-joe joe joe # srv --add schedule-joe The uscheduleconf program will create the appropriate directories and run files to be run. This consists of the traditional /var/service/schedule-user run directory and a ~/.uschedule directory in the user's home directory. The /var/service/schedule-user/run script looks as follows: #!/bin/execlineb /bin/fdmove -c 2 1 /bin/cd /home/user/.uschedule /sbin/chpst -u user ./run Essentially, the script is starting /home/user/.uschedule/run as that particular user. The user is perfectly capable of executing ./run on their own, but it won't be supervised. Keep in mind that this isn't really a security issue; the user can have their own scheduler running but it won't be supervised (so no restart if it's killed) and it can never do anything that the user wouldn't already be able to do. The user's ./run script is simply: #!/bin/execlineb /bin/fdmove -c 2 1 /sbin/chpst -e ./env /usr/bin/uscheduled -d /home/user/.uschedule Scheduling tasks with uscheduleScheduling tasks with uschedule is similar in concept to scheduling tasks with at. The uschedule(1) manpage provides a lot of information on the various options of using and manipulating uschedule jobs, and the uschedulecmd(1) manpage provides information on the uschedulecmd program, which does the actual scheduling. For instance:
$ uschedulecmd -e -i myjob ${HOME}/bin/myjob.sh
This command adds the job titled "myjob" to uschedule. "myjob" is the name of the job; the contents of the job are the ${HOME}/bin/myjob.sh file. Now that the job has been added, it must be scheduled: $ uschedule -c 1 myjob +03:00:00 This does the actual scheduling of "myjob". This command tells uschedule to execute "myjob" in exactly 3 hours. With uschedulecmd there are a few options you can use, notably the -e option. This option instructs uschedulecmd to make an exact copy of the current environment (variables and all) for the new job. The -i option gives the job a name (in the above case, "myjob"). This name must be unique, and must not contain colons, slashes, or dots. If that option is not used, a unique numerical ID will be assigned and printed to standard output. Beyond that, uschedulecmd does no scheduling. All it does is create new jobs for uschedule to schedule. If you do not use uschedule to schedule the job, it will remain until it is removed and will never be executed. uschedule is the "driver" of the system, in that it sets up the job to be run. It has a variety of options, some of which will be noted here; the rest are covered in the manpage. The -c option tells uschedule how often to run the job; in the above it will be executed exactly one time. If you do not specify a count, it will assume a value of "0" and will be repeated forever (i.e. if we omitted the count in the above command, "myjob" will be executed every 3 hours). The final option to provide is the TIMESPEC which tells uschedule when the job needs to be executed. The TIMESPEC is not the same as what is used by at. Here are a few examples:
The format of the TIMESPEC consists of two or three words. The first (optional) words specify a day-of-week, the next specify the year, month, and day-of-month, and the last specifies the hour, minutes, and seconds. Words must be separated by one space. Proceeding the TIMESPEC with the "+" character indicates to execute the job at now+TIMESPEC. Job loggingJob execution information can be viewed by examining ~/.uschedule/log/current; this is the log that uscheduled outputs to about job exectution: 2007-02-09_14:35:15.07130 uscheduled[1472]: started pid 13576 for job @0000000000000000:myjob:3600:1: Y2007M1D9h14m35s15:::::0 2007-02-09_14:35:15.09255 uscheduled[1472]: deleted job myjob 2007-02-09_14:35:22.79926 uscheduled[1472]: processs 13576 terminated with code 0 Listing jobs in the queueYou can see what jobs are scheduled by using uschedulelist. Any pending jobs will be printed out. If you wish to see all of the registered commands that uschedule knows of, use uschedulelist -c: $ uschedulelist -c myjob size: 46 links: 1 modification: 2007-02-08 14:48:13 Removing finished jobsJobs are never removed once they are completed. In order to remove a job that will not be executed again, use uschedulerm. There are two modes for uschedulerm:
In other words, to entirely get rid of a job, you must use the -c option. If you want to delete a job that has not been completed yet, or a job that is persistent, the first invocation will delete any pending jobs scheduled. The second invocation deletes the actual job itself: $ uschedulerm -c myjob Resources |
![]() |
|
|
| |||