放送の基本メッセージをshutdown
別のものに変更できますか?
ベストアンサー1
〜のように@ゼルダこれらのメッセージはハードコードされていることに注意してください。追加のビットでメッセージを変更する代わりにそれを変更したい場合:
$ sudo shutdown -h +120 Save your work.
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);
}