root@calleva:/var/spool/cron/atjobs# echo "sleep 3000" | at 20:58
warning: commands will be executed using /bin/sh
job 161 at Sat Jun 3 20:58:00 2023
root@calleva:/var/spool/cron/atjobs# ls
a000a101acba0e
root@calleva:/var/spool/cron/atjobs# cat a000a101acba0e
#!/bin/sh
# atrun uid=0 gid=0
# mail root 0
umask 22
LANGUAGE=en_GB:en; export LANGUAGE
PWD=/var/spool/cron/atjobs; export PWD
LOGNAME=root; export LOGNAME
XDG_SESSION_TYPE=tty; export XDG_SESSION_TYPE
MOTD_SHOWN=pam; export MOTD_SHOWN
HOME=/root; export HOME
LANG=en_GB.UTF-8; export LANG
SSH_CONNECTION=192.168.0.12\ 60848\ 192.168.0.113\ 22; export SSH_CONNECTION
XDG_SESSION_CLASS=user; export XDG_SESSION_CLASS
USER=root; export USER
SHLVL=0; export SHLVL
XDG_SESSION_ID=1202; export XDG_SESSION_ID
XDG_RUNTIME_DIR=/run/user/0; export XDG_RUNTIME_DIR
SSH_CLIENT=192.168.0.12\ 60848\ 22; export SSH_CLIENT
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/root/.dotnet/tools:/root/bin:/opt/mssql-tools/bin:/usr/games; export PATH
DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/0/bus; export DBUS_SESSION_BUS_ADDRESS
SSH_TTY=/dev/pts/5; export SSH_TTY
OLDPWD=/root; export OLDPWD
cd /var/spool/cron/atjobs || {
echo 'Execution directory inaccessible' >&2
exit 1
}
sleep 3000
root@calleva:/var/spool/cron/atjobs# atq
161 Sat Jun 3 20:58:00 2023 a root
root@calleva:/var/spool/cron/atjobs#
a000a101acba0e
파일이 대기열 항목에 해당하는지 알 수 있는 방법이 있습니까 161
?
답변1
전체를 보면서원천우리는 발견한다
writefile(time_t runtimer, char queue)
...
(void)snprintf(ppos, sizeof(atfile) - (ppos - atfile),
"%c%5lx%8lx", queue, jobno, (unsigned long) (runtimer / 60));
그래서 a000a101acba0e
부터
a
"에"에 대한000a1
16진수로 작업 번호 161입니다. 확인해보세요echo $((16#00a1))
01acba0e
에포크 이후 작업을 실행하는 시간(분)입니다. 으로 확인하세요echo "obase=16;$(date +%s)/60" | bc
.
답변2
#!/bin/sh
for f in /var/spool/cron/atjobs/*; do
fn=$(basename $f)
jobHex=$(echo "$fn" | cut -c2-6 | tr "a-z" "A-Z")
jobDec=$(echo "ibase=16;$jobHex" | bc)
tHex=$(echo "$fn" | cut -c7-14 | tr "a-z" "A-Z")
tDec=$(echo "ibase=16;$tHex * 3C" | bc) # 0x3C is 60.
tT=$(date --date="@$tDec" +%Y-%m-%dT%H-%M)
cmd=$(tail -2 $f | head -1)
echo "Job $job at $tT is $cmd"
done