如何将 at 命令外壳从 sh 更改为 bash?
运行时at
,我收到消息warning: commands will be executed using /bin/sh
:
at 23:33
warning: commands will be executed using /bin/sh
Run Code Online (Sandbox Code Playgroud)
如何将默认外壳设置为/bin/bash
而不是/bin/sh
您无法更改 的默认外壳at
,它/bin/sh
与源代码中一样是硬编码的。
的源代码at
阐明了这一点,来自at.c
:
Run Code Online (Sandbox Code Playgroud)/* POSIX.2 allows the shell specified by the user's SHELL environment variable, the login shell from the user's password database entry, or /bin/sh to be the command interpreter that processes the at-job. It also alows a warning diagnostic to be printed. Because of the possible variance, we always output the diagnostic. */ fprintf(stderr, "warning: commands will be executed using /bin/sh\n");
实施,来自atd.c
:
if (execle("/bin/sh", "sh", (char *) NULL, nenvp) != 0)
Run Code Online (Sandbox Code Playgroud)
手册页相应地符合:
at 和批处理从标准输入或指定文件读取命令,这些命令将在稍后执行,使用/bin/sh。
这让您重新编译自己的副本,作为满足您需求的唯一解决方案。
看着man at
,好像不能换壳了。
但是,您可以在at
的 SH shell内的 Bash shell 中启动您的命令,如下所示:
at 01:23 <<< "bash -c 'notify-send \"running from $SHELL\"'"
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
914 次 |
最近记录: |