Changing shutdown broadcast message

broadcastdefaultsshutdown

Is it possible to change the default message broadcasted by shutdown to something else?

Best Answer

As @Zelda mentioned the messages are hardcoded. If you want to change it beyond amending the message with additional bits:

$ sudo shutdown -h +120 Save your work.

You'll need to recompile shutdown, creating your own executable that includes the customized message.

For example, here's a sample source file, shutdown.c. Lines such as these would need to be changed, and the .c files would need to be rebuilt.

/*
 *      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);
}
Related Question