更改关机广播消息

tal*_*les 5 shutdown defaults broadcast

是否可以将广播的默认消息更改shutdown为其他内容?

slm*_*slm 6

正如@Zelda提到的,这些消息是硬编码的。如果你想改变它而不是用额外的位修改消息:

$ sudo shutdown -h +120 Save your work.
Run Code Online (Sandbox Code Playgroud)

您需要重新编译shutdown,创建您自己的包含自定义消息的可执行文件。

例如,这里有一个示例源文件 shutdown.c。需要更改诸如此类的行,并且需要重建 .c 文件。

/*
 *      Tell everyone the system is going down in 'mins' minutes.
 */
void warn(int mins)
{
        char buf[MESSAGELEN + sizeof(newstate)];
        int len;

        buf[0] = 0;
        strncat(buf, message, sizeof(buf) - 1);
        len = strlen(buf);

        if (mins == 0)
                snprintf(buf + len, sizeof(buf) - len,
                        "\rThe system is going down %s NOW!\r\n",
                        newstate);
        else
                snprintf(buf + len, sizeof(buf) - len,
                        "\rThe system is going DOWN %s in %d minute%s!\r\n",
                                newstate, mins, mins == 1 ? "" : "s");
        wall(buf, 0);
}
Run Code Online (Sandbox Code Playgroud)