How do I print contents of at jobs?

I have a Debian box with some jobs scheduled using at. I know I can list the jobs with their times using atq, but is there any way to print out their contents, apart from peeking into /var/spool/cron/atjobs?


at -c jobnumber will list a single job. If you want to see all of them, you might create a script like

#!/bin/bash
MAXJOB=$(atq | head -n1 | awk '{ print $1; }')
for each in $(seq 1 $MAXJOB); do echo "JOB $each"; at -c $each; done 

Probably there's a shorter way to do that, I just popped that out of my head :)


Building upon previous responses, this lists each job's line from atq showing job number and scheduled time and then just the command to be run, sorted chronologically (rather than job number):

for j in $(atq | sort -k6,6 -k3,3M -k4,4 -k5,5 |cut -f 1); do atq |grep -P "^$j\t" ;at -c "$j" | tail -n 2; done

producing, e.g.

48  Fri Mar 10 15:13:00 2017 a root
/usr/local/bin/a-command

47  Fri Mar 10 15:14:00 2017 a root
/usr/local/bin/another-command