如何使用“ at”“”?

发布于 2025-01-22 07:08:59 字数 381 浏览 3 评论 0原文

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

花想c 2025-01-29 07:08:59

1。

如何制作“”在“ bash而不是shell

”运行脚本

echo '/bin/bash /home/user/test.sh' | at now

2运行脚本。

但是,您的问题可能会更简单:

您必须在从相对路径的程序/脚本的名称之前添加./,它可以保护您免于意外地从a中运行程序本地目录。
该点代表当前目录,它实际上告诉您的外壳:“ 从当前目录运行此程序”。

当您将绝对路径指定到可执行文件时,您不以./的前缀为前缀,因为它是1。无效,因为该可执行文件不在当前目录2中。

所以这应该足够:

echo '/home/user/test.sh' | at now

3。

要说明哪个shell(解释器)应运行脚本,只需添加 shebang 作为第一行:

#!/bin/bash

您的脚本扩展名无关紧要,无论是.sh> .bash,甚至根本没有扩展。

1 .

how to make "at" run scripts as bash instead of shell

echo '/bin/bash /home/user/test.sh' | at now

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:

echo '/home/user/test.sh' | at now

3 .

To state what shell (interpreter) should run your script, simply add a shebang as its first line:

#!/bin/bash

Your script's extension does not matter, be it .sh, .bash or even no extension at all.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文