|
Softpanorama |
May the source be with you, but remember the KISS principle ;-)
Softpanorama Search
|
| News | Books | Minitutorial | Recommended Links | Examples | |
| Batch | Cron | cron.allow | cron.deny | Etc |
At command exists in both Unix and Windows although with different syntax:
/usr/bin/at [-c| -k| -s] [-m] [-f file] [-p project] [-q queuename] timespec…
/usr/bin/at [-c| -k| -s] [-m] [-f file] [-p project] [-q queuename] -t time
The difference is that is first case time specification can be more complex (see below) whicle in the second case time should be specified using the format of the touch utility.
The idea of at command is periodic or as it usually called "one time command scheduling". In this sense it is complementary to cron which usually is used to schedule periodic jobs. In essence at is a special version of cron and like cron it is controlled by two files that list users one per line and are similar to cron control files cron.allow and cron.deny and control the behavior of the command:
Actually Unix administrators usually hardlink them to cron files to avoid synchronization problem.
The most important ability of at command is the its ability to operate in relative time terms. There are several important relative time frames used:
The optional increment after time specification in at command permit to specify offset from the time. It should be a number preceded by a plus sign (+) with one of the following suffixes:
The spacing is quite flexible as long as there are no ambiguities. For example:
at 0815am Jan 24 at 8 :15amjan24 at now "+ 1day" at 5 pm FRIday at '17 utc+ 30minutes'
The singular forms are also accepted, for example
at now + 1 minute
The keyword next can be used as an equivalent to an increment + 1. For example,:
at 2pm + 1 week
at 2pm next week
The last two are equivalent commands.
One can also use at for periodic but dynamic rescheduling of jobs. In such case at can be specified inside the job with new, dynamic interval.
Simplified (and actually wrong as if interval is fixed crontab is a more appropriate vehicle for such work) example, can be something like a script named my.daily which we force to run every day by invoking at inside the script itself:
# my.daily runs every day at now tomorrow < my.daily daily-processing
System V
BSD
/usr/xpg4/bin/at [-c| -k| -s] [-m] [-f file] [-p project] [-q queuename] -t time
/usr/xpg4/bin/at [-c| -k| -s] [-m] [-f file] [-p project] [-q queuename] timespec…
/usr/xpg4/bin/at -l [-p project] [-q queuename] [at_job_id...]
/usr/xpg4/bin/at -r at_job_id. ..
/usr/xpg4/bin/batch [-p project]
Two "twins" at and batch are very similar with batch being alias to at with supplied "now" time of execution.
Commands of the forms:
/usr/bin/batch [-p project] /usr/xpg4/bin/batch [-p project]
are respectively equivalent to:
/usr/bin/at -q b [-p project] now /usr/xpg4/bin/at -q b -m [-p project] now
At the same time at is quite different animal than cron: "at" preserves the environment in which it was invoked, while cron does not (it executes command in its own "cron" environment, and you should not expect that PATH and other valuables will be preserved).
The at utility is pipable: it can reads commands from standard input and submit a job to be executed immediately (like in example below) or at a later time.
echo "perl myjob" | at now
The at-job is executed in a separate invocation of the shell, running in a separate process group with no controlling terminal, except that the environment variables, current working directory, file creation mask (see umask(1)), and system resource limits (for sh and ksh only, see ulimit(1)) in effect when the at utility is executed is retained and used when the at-job is executed.
When the at-job is submitted, the at_job_id and scheduled time are written to standard error. The at_job_id is an identifier that is a string consisting solely of alphanumeric characters and the period character. The at_job_id is assigned by the system when the job is scheduled such that it uniquely identifies a particular job.
User notification and the processing of the job's standard output and standard error are described under the -m option.
Like with cron two files that list users one per line and are similar to cron control files control the behavior of the command:
Rules
If that file does not exist, the file /usr/lib/cron/at.deny is
checked to determine if the user should be denied access to at.
! bad user (webservd) Fri Apr 21 14:47:49 2006
That can also happen with human accounts if password aging was turned on.
Apparently if the password expires cron jobs do not run.
The batch utility reads commands to be executed one after another and is equivalent to at now. The difference is that the queue used is a special at queue, that exists specifically for batch jobs. Execution of submitted jobs can be delayed by limits on the number of jobs allowed to run concurrently. See queuedefs(4).
If the -c, -k, or -s options are not specified, the SHELL environment variable by default determines which shell to use.
For /usr/xpg4/bin/at and /usr/xpg4/bin/batch, if SHELL is unset or NULL, /usr/xpg4/bin/sh is used.
For usr/bin/at and /usr/bin/batch, if SHELL is unset or NULL, /bin/sh is used.
The following options are supported:
If -m is not used, the job's standard
output and standard error is provided to the user by means of mail, unless they
are redirected elsewhere; if there is no such output to provide, the user is
not notified of the job's completion.
The following operands are supported:
In the "C" locale, the following describes the three parts of the time specification string. All of the values from the LC_TIME categories in the "C" locale are recognized in a case-insensitive manner.
If no date is given, today is assumed if the given
time is greater than the current time, and tomorrow is assumed
if it is less. If the given month is less than the current month (and no
year is given), next year is assumed.
at 2pm + 1 week at 2pm next week
The format of the at command line shown here is guaranteed only for the "C" locale. Other locales are not supported for midnight, noon, now, mon, abmon, day, abday, today, tomorrow, minutes, hours, days, weeks, months, years, and next.
Since the commands run in a separate shell invocation, running in a separate process group with no controlling terminal, open file descriptors, traps and priority inherited from the invoking environment are lost.
$ at -m 0730 tomorrow sort < file >outfile <EOT>
$ at now + 1 hour <<! diff file1 file2 2>&1 >outfile | mailx mygroup !
This sequence can be used at a terminal:
$ batch sort <file >outfile <EOT>Example 6 Redirecting Output
This sequence, which demonstrates redirecting standard error to a pipe, is useful in a command procedure (the sequence of output redirection specifications is significant):
$ batch <<! diff file1 file2 2>&1 >outfile | mailx mygroup !
|
|||||||
Ok, I got it! The issue was within the pam.conf and we were missing the following line:
cron account required pam_projects.so.1
Thanks for the help!
After some research I found out that Solaris logs crontab messages to /var/cron/log (which is actually pretty predictable logging for Solaris). The log entries for the updating of the sunfreeware mirror looked something like this:
> CMD: /usr/local/bin/update-sunfreeware
> ftp 21022 c Fri Jul 30 06:00:00 2004
! bad user (ftp) Fri Jul 30 06:00:00 2004
So we are talking about a bad user here. Well actually the user is all there and running in /etc/passwd and /etc/shadow. But hey wait, the FTP account is locked. Well I found that normal behaviour, but guess what, crontab expects a password there, else the account is not good and is a bad user!Recommended Links
In case of broken links please try to use Google search. If you find the page please notify us about new location
Copyright © 1996-2009 by Dr. Nikolai Bezroukov. www.softpanorama.org was created as a service to the UN Sustainable Development Networking Programme (SDNP) in the author free time. Submit comments This document is an industrial compilation designed and created exclusively for educational use and is placed under the copyright of the Open Content License(OPL). Site uses AdSense so you need to be aware of Google privacy policy. Original materials copyright belong to respective owners. Quotes are made for educational purposes only in compliance with the fair use doctrine.
Disclaimer:
Last modified: August 08, 2009