Tag Info

Hot answers tagged

22

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 ...


13

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.


10

You could do something like this: for i in $(atq | cut -f 1); do atrm $i; done


10

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 ...


9

You can run this command to remove all the jobs at the atq for i in `atq | awk '{print $1}'`;do atrm $i;done


8

You could use the command 'at' at now +4 hours -f commandfile Or at now +$((($RANDOM % 10)+2)) hours -f commandfile


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 ...


6

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


6

Option 1 Schedule your job in cron to run every hour (or every other hour), but prefix the job with something like this (presuming you have SHELL=/bin/bash in your crontab): [ $[RANDOM % 12] -eq 0 ] || exit 0; YOUR_JOB_HERE Then there will be an approximately* one in twelve chance of the job running each time its scheduled. Option 2 Schedule a cron job ...


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: ...


5

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 ...


5

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 ...


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 ...


4

Since at defaults to reading from standard input, you can just do this: echo /path/to/script argument | at 17:45


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, ...


3

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.


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

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 ...


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

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 need to set the display variable, but this is done as: #!/bin/bash export DISPLAY=":0" gedit and then at now + 1 minute -f test.sh works for me on Ubuntu 14.04.1 LTS


2

You could write an init-script that cancels all sheduled at-jobs on shutdown or reboot. I am not sure about Arch-Linux - is there a /etc/sysconfig/at or something similar? Perhaps it is just a config-switch you have to flip over...


2

You send ctrl-D like this: send "\004" http://wiki.tcl.tk/3038 http://expect.sourceforge.net/FAQ.html#q54


2

You could use a plain shell script: #! /bin/sh # Usage: setupkill.sh time process. echo /home/jagan/p/killprocess "$2" | at "$1" (Sorry, I don't know expect so this is just a simple workaround.)


2

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


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

Essential on most systems, is a daemon, usually atd


2

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 ...



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