Car*_*ega 3 bash cron shell-script at
使用at
命令我可以在将来运行一次脚本:
at now + 1 minutes -f ~/script.sh
Run Code Online (Sandbox Code Playgroud)
或者现在运行一个字符串命令,然后在将来返回结果:
echo "xyz" >> ~/testtest.txt | at now + 1 minute
Run Code Online (Sandbox Code Playgroud)
我怎样才能传递一个在未来运行而不是现在运行的字符串命令(根据示例 2)(根据示例 1)?例如
at now + 1 minutes -SOMEFLAG 'echo "xyz" >> ~/testtest.txt'
Run Code Online (Sandbox Code Playgroud)
谢谢
使用 here-document 传递脚本以稍后在命令行上运行:
at now + 1 minute <<'END_AT'
echo 'xyz' >> ~/testtest.txt
END_AT
Run Code Online (Sandbox Code Playgroud)
here-document 被引用(通过使用<<'END_AT'
而不是<<END_AT
)来阻止当前 shell 扩展脚本文本中的变量等。该文档将被传递到at
标准输入。