如何使用“ at”“”?
Google解决我的问题很痛苦,因为它使用了应用程序“ AT” :) 因此,我正在尝试进行长期运行的操作(我知道我可以为Cron添加一些特定的条目,但我仍在学习新内容”),我决定在“应用程序”上使用“”。 事实是,它无法正常运行,我认为这是因为在运行应用程序中,默认情况下是bash的外壳。
echo "./home/user/test.sh" | at now
warning: commands will be executed using /bin/sh
job 5 at Sun Apr 17 12:34:00 2022
我还尝试了我在SOF上找到的其他胎面的建议,并尝试为我的脚本创建.bash脚本扩展 所以我的问题是 - 如何将“在”运行脚本作为bash而不是shell?
It was a pain to google solutions for my problem since it is using application "at" :)
So the thing is, I am trying to run long runnng operation (I know that I could add some specific entry to cron, but I am still learning new stuff") and I decided to use "at" application.
The thing is that it does not run properly and as I believe it is because at runs applications as shell intead of bash by default.
echo "./home/user/test.sh" | at now
warning: commands will be executed using /bin/sh
job 5 at Sun Apr 17 12:34:00 2022
I've also tried suggestion from other tread that I've found on SOF and tried to create .bash script extensions for my script/s
So my question is - how to make "at" run scripts as bash instead of shell?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
1。
2运行脚本。
但是,您的问题可能会更简单:
您必须在从相对路径的程序/脚本的名称之前添加
./
,它可以保护您免于意外地从a中运行程序本地目录。该点代表当前目录,它实际上告诉您的外壳:“ 从当前目录运行此程序”。
当您将绝对路径指定到可执行文件时,您不以
./
的前缀为前缀,因为它是1。无效,因为该可执行文件不在当前目录2中。所以这应该足够:
3。
要说明哪个shell(解释器)应运行脚本,只需添加 shebang 作为第一行:
您的脚本扩展名无关紧要,无论是
.sh
,> .bash
,甚至根本没有扩展。1 .
2 .
However your problem might be simpler:
You must add
./
before the name of a program/script run from a relative path, which protects you from accidentally running a program from a local directory.The dot represents the current directory and it literally tells your shell: "from current directory run this program".
When you specify the absolute path to your executable, you do not prefix it with
./
, because it is 1. invalid, as that executable is not in your current directory 2. needless, as by using the absolute path you already confirm that it is not a mistake and you know what you are doing.So this should be enough:
3 .
To state what shell (interpreter) should run your script, simply add a shebang as its first line:
Your script's extension does not matter, be it
.sh
,.bash
or even no extension at all.