shellat-job

At command : job number


I'm writing a bash script where I use the command at.

How can I get the number of a job created with at? (In order to delete if needed.)

The command actually returns nothing. I get a response from the system when I use at in the shell, but I can't capture it. It's not coming from the command itself.


Solution

  • I'm assuming you're on a Unix / Linux system. This answer was tested on a Solaris Unix machine. Linux (Red Hat) is similar but the at job id format is a simple short number.

    There's no actual PID produced until the job actually runs, but an at job id is returned to standard error.

    > at -t 07141116 2> at out < commandfile
    > cat at.out
    job 1436868960.a at Tue Jul 14 11:16:00 2015
    

    You can check its status with the at -l command

    > at -l
    1436868960.a    Tue Jul 14 11:16:00 2015