はじめに:
コマンドatq 実行を待機しているatジョブとその実行時間のリストを表示します。ジョブ番号で始まる各行。
コマンドat-c JobNumber 環境変数を含むジョブの内容を教えてくれます。
私が欲しかったのは、ジョブのリストを提供するコマンドです(コマンド atq のように) )ただし、各ジョブ行の後に実行されるコマンドが続くように拡張されています。除外 それらの環境変数。例:
34 Tue Jan 17 10:22:00 2017 a root
Commands
35 Tue Jan 24 17:50:00 2017 a root
Commands
28 Tue Dec 13 23:00:00 2016 a root
Commands
24 Mon Nov 14 20:27:00 2016 a root
Commands
31 Sun Jan 15 00:21:00 2017 a root
Commands
うーん…これを表示するコマンドが見つかりませんでした。そこで、私はその仕事をするこのbashスクリプトを作成しました:
#!/bin/bash
# Description: Displays all 'at' jobs and their respective commands
# Syntax: atlist.sh
# Changes: 05.11.2016 First implementation
########################################################################
# Get the short jobs list and expand from there
atq | while read line ; do
jobnr=$(echo $line | awk '{print $1}')
echo $line
# Pickup all the command lines after first line matching '}'.
# This excludes all the environment variables and the at exit line.
# Exclude the matching '}' line and empty lines
# Add an offset of 8 chars to each command line.
at -c $jobnr | sed -e '1,/^\}/d' -e '/^$/d' -e 's/^/ /'
done