2

I am very new to using at and am wondering how to display the command by a scheduled job.

postgres@dcjsn-jv2526:/opt/db/backup/postgres/dumps> atq
29      Wed Nov  2 18:55:00 2022 a postgres

I see there is a job 29 scheduled for a certain time by a certain user. Now I want to examine the command to be executed. How do I achieve that? There is nothing on this in the manpage.

vrms
  • 139

2 Answers2

1

The command

at -c 29

should do it. Note that the job file includes your full environment, so scroll down to the bottom if necessary to see the script that is executed.

The at(1) man page says:

       -c     cats the jobs listed on the command line to standard output.

You need to be superuser to examine jobs of other users though.

NickD
  • 2,926
0

It can also be done in this way

┌──[root@vms83.liruilongs.github.io]-[/var/spool/at]
└─$ls /var/spool/at/
a0000101a80dd0  a0000201a80dd0  spool
┌──[root@vms83.liruilongs.github.io]-[/var/spool/at]
└─$cat a0000201a80dd0

  • How would you connect the cryptic filename with a particular at job? – Kusalananda Nov 02 '22 at 16:50
  • a0000{job_id}01a80dd0 It looks like this – 山河以无恙 Nov 02 '22 at 19:35
  • You need to be superuser to do the ls of /var/spool/at I believe. OTOH, at -c 29 will work as long as you are the owner of the job. I also tried to cat the file directly and I still get permission denied even though I own it: the directory perms don't allow it. So even if you can guess the filename, you won't be able to see it unless you are the superuser. – NickD Nov 02 '22 at 20:33