我尝试安排一个命令在 2 分钟后执行
at -c "ls -l" now + 2 minutes
它以多种方式失败
$ echo "open 'Google Chrome' " | at now + 2 minutes
job 15 at Mon Oct 29 13:31:42 2018
我怎样才能让它工作?
run "open 'Google Chrome' " at now + 2 minutes
我试过了,它不起作用
$ at now
at>ls -l
at>^D
at> <EOT>
job 18 at Mon Oct 29 15:55:00 2018
答案1
您误解了该-c
选项的作用。该选项打印创建at
新作业时由命令创建的临时文件的内容。at
这是创建简单at
作业的一种方法:
$ at now + 2 minutes
at> ls -l
at> CTRL-D <---- Press Control Key + D Key simultaniously
at> <EOT>
job 2 at Mon Oct 29 03:34:00 2018
$
at
这是为该作业创建的临时文件的内容:
$ at -c 2
#!/bin/sh
# atrun uid=1000 gid=1000
# mail student 0
umask 2
XDG_VTNR=1; export XDG_VTNR
SSH_AGENT_PID=3010; export SSH_AGENT_PID
XDG_SESSION_ID=1; export XDG_SESSION_ID
.... lots more environment ....
cd /home/student || {
echo 'Execution directory inaccessible' >&2
exit 1
}
${SHELL:-/bin/sh} << 'marcinDELIMITER689a131f'
ls -l
marcinDELIMITER689a131f
$