Tag Info

Hot answers tagged

20

Bernhard's reply is correct: in multi-user systems, the ability to execute heavy programs at some ungodly hours of the night is especially convenient, for both the person submitting the job, and his coworkers. It is part of "playing nice". I did most of my Ph.D. computations this way, combining the script with the nice command which demoted the priority of ...


12

I use the at command when I need to do some heavy processing on data, which I want to have executed during the night, when I am not behind my computer. Of course I could start the process just after I leave, but this is something I tend to forget. The result of the command is not different from regularly execution of the script or command.


9

Because at does not execute commands in the context of your logged in user session. The idea is that you can schedule a command to run at an arbitrary time, then log out and the system will take care of running the command at the specified time. Note that the manual page for at(1) specifically says (my emphasis): The user will be mailed standard error ...


7

From the cron man page: When executing commands, any output is mailed to the owner of the crontab (or to the user named in the MAILTO environment variable in the crontab, if such exists). The children copies of cron running these processes have their name coerced to uppercase, as will be seen in the syslog and ps output. So you should check ...


5

When you have questions such as this always consult the man pages. They can be very enlightening. What it does excerpt from at man page NAME at, batch, atq, atrm - queue, examine or delete jobs for later execution DESCRIPTION at and batch read commands from standard input or a specified file which are to be executed at a later ...


5

A restart of the atd service did not reset the job id as we suspected: Example some test submissions $ at -f test.bash now job 105 at Mon Sep 23 20:04:00 2013 $ at -f test.bash now job 106 at Mon Sep 23 20:04:00 2013 double checking the spool dir $ sudo ls -l /var/spool/at/spool/ total 0 a restart of atd $ sudo /etc/init.d/atd restart Stopping atd: ...


4

The program that constitutes the at job is a child of the atd (at daemon) process, not of the shell where you run at. So it does not inherit the current shell's environment. The at system arranges to copy the environment (and the working directory and a few more obscure thing), but it omits a few variables. In particular, the DISPLAY variable is not copied ...


4

Depending on your Linux distribution and the kind of installation (minimal, desktop-centric, etc.) at (and atd the at job scheduler daemon) is installed by default or not. To verify it you can issue commands like: $ which at /usr/bin/at $ which atd /usr/bin/atd $ yum whatprovides atd # to get the package name $ yum info pkg-name # to see if it is ...


4

CentOS at configuration file is in /etc/sysconfig/atd according to the man page, the mail notification is as follows: If the file /var/run/utmp is not available or corrupted, or if the user is not logged on at the time at is invoked, the mail is sent to the userid found in the environment variable LOGNAME. If that is undefined or empty, ...


4

As @MichaelKjörling has explained it any output that's produced by your at job will be captured and sent to you via email. If you don't have a running MTA - Mail Transfer Agent on your box then the email may be in limbo and you'll not know that at is even attempting to do this. A MTA, is a program such as sendmail or postfix that can "deliver" email to an ...


4

You can execute batch jobs in UNIX / Linux using any one of the three commands — at, batch or cron. Schedule an at job using specific date and time Syntax: $ at time date For example, to schedule a job at 11 am on May 20, use the following at command. $ at 11 am may 20


3

From usr/share/doc/at/timespec, it doesn't look like it. But you can always use date to convert your timestamp, eg: at "$(date --date=@1393419435 +'%D %T')" date takes a timestamp in seconds, so don't forget to trim fractions of seconds if needed.


3

you can achieve running it from a different shell changing the script shebang. Some typical shebang lines: #!/bin/sh — Execute the file using sh, the Bourne shell, or a compatible shell #!/bin/csh -f — Execute the file using csh, the C shell, #!/usr/bin/perl -T — Execute using Perl with the option for taint checks #!/usr/bin/php — Execute the file using ...


3

When does a job become a past job? If you turn on the system at 7:59:50 and the at daemon starts at 8:00:01, should the job be executed? What if the daemon starts at 7:59:59 but takes two seconds to read all of its files? You decide! Start your job with a time check, and abort if the time is past. export execute_by_date=$(date +%s 'tomorrow 8:01') at ...


3

You can pipe the output of atq to sort and use the k switch (sort via key) and M (month-sort) to list your jobs by date. For example, the default output would look like: atq 5 Mon Dec 10 19:00:00 2012 a jason 6 Tue Jan 15 05:00:00 2013 a jason 4 Thu Dec 6 19:00:00 2012 a jason Piping through sort: atq | sort -r -k3M -k4 6 Tue Jan 15 05:00:00 2013 ...


2

From man at: at and batch read commands from standard input or a specified file which are to be executed at a later time, using /bin/sh. So just send the command you would type in interactively to at as input: echo 'rm that.file' | at now+10min


2

Under Linux, at always warns you that it will execute the specified commands with /bin/sh, rather than your favorite shell. You cannot suppress this message, it's hard-coded in the source code. The command you pass is interpreted by /bin/sh. This command can be the path to a script if you like; then /bin/sh will execute the script program, causing the ...


2

At jobs are executed using a shell interpreter (on Linux, it is usually /bin/sh). It means that any command you are going to run as at job can be tracked by a PID number of the shell which is going to run that command. You can simply catch this PID with special shell variable $$. You can save it to a file (single quotes are mandatory to not expand it in your ...


2

at -c 42 where the number is the job number listed by atq. c is for “cat”. Non-antique Linux and *BSD implementations support the -c option, as does HP-UX. I think System V, including modern Solaris, doesn't have a way to list the content of pending jobs. On AIX, it's at -lv.


2

The FreeBSD and Solaris manuals are clear: if at.allow exists, at.deny is ignored. The Linux manual is slightly less explicit but the behavior is the same. Despite the convergence of BSD and Solaris, this is not universal. On AIX, if a user is listed in both at.allow and at.deny, then he cannot use at.


1

You could incorporate the timeout into your job. timeout "$(($(date +%s -d '7am') - $(date +%s)))" wget -c http://example.com/wibble Alternatively, have your job write its process ID somewhere so that you can kill it. In the 2am job: echo $$ >~/.at.download.pid wget -c http://example.com/wibble rm ~/.at.download.pid In the 7am job: if [ -e ...


1

at does not support decimals: at now + 1.5 minutes syntax error. Last token seen: . Garbled time Working version: at now + 5000 minutes at> wall "POC" at> <EOT> job 8 at Thu Sep 12 23:20:00 2013 I guess your best way is to remove what is right of the '.'. Also at does not seem to accept seconds, from the man page: " now + ...


1

The above answers are the standard/"right" way to do it. Another approach that's simpler from a more "end user" point of view is to have any scheduled or background task write it's output to a "log" file. The file can be anywhere on your system, but if the task is running as root (from cron, etc.), then somewhere under /var/log is a good place to put it. I ...


1

If the output on error is printed to stderr, and all of the output in case of normal exit to stdout you can redirect the output when you start the command with at. at command > /dev/null By default at emails both stdout and stderr (from the man page): The user will be mailed standard error and standard output from his commands, if any. ...


1

With zsh for simple commands: my-batch() {print -r -- ${(qq)@} | batch} my-batch python some_longrunning_computational_script.sh would do it. If you need more complex things like loops or redirections, you could do: my-batch eval 'for i in ...; done' my-batch eval 'echo test > /some/file' But remember to use sh, not zsh syntax. If you want to be ...


1

For more AIX 6 systems you can simply do: atrm - Ref: http://pic.dhe.ibm.com/infocenter/aix/v6r1/index.jsp?topic=%2Fcom.ibm.aix.cmds%2Fdoc%2Faixcmds1%2Fatrm.htm


1

I would recommend following the advice of @warl0ck in the general case -- create a new script, e.g. /path/to/newscript: #!/bin/bash /path/to/script argument and then run that using at: at -f /path/to/newscript 17:45 This makes it easy to adjust whatever arguments are needed, run multiple commands, etc. Alternatively, for occasional or one-off use, ...


1

My vote is for the cron daemon. If you need to run it at specific times of the day, but not at the same time each day, I'd create a crontab with one entry per day range with an specific execution time: Some examples taken from crontab(5): # run five minutes after midnight, every day 5 0 * * * command # run at 2:15pm on the first of every month 15 14 ...



Only top voted, non community-wiki answers of a minimum length are eligible