0

I am using a bash script with the shutdown command to halt my system. I know that shutdown can print a message as an argument. Here's my current command:

shutdown -h now "Shutdown complete. You may now unplug the power."

However, this prints my message before the shutdown command does its thing, and so I see a ton of other messages afterwards, such as "INIT: Sending processes the TERM signal" and "Unmounting local filesystems..."

I want to print a final message at the end of the halt, so that the user knows when it is safe to unplug the power. How can I do this?

(I am on an embedded system running Petalinux 2019.1.)

terdon
  • 234,489
  • 66
  • 447
  • 667

1 Answers1

1

This is a semi-educated guess:

This would be saved to /etc/rc0.d/K01zzz_goodbye_message

#!/bin/sh
echo "Shutdown will complete soon. Unplug me."
glenn jackman
  • 84,176
  • 15
  • 116
  • 168
  • I do see a S90halt script there, I could edit it, or make the new one as you suggest. I'll try these out tomorrow and see what works – Eliezer Miron Jan 13 '21 at 01:58
  • The `S` scripts and the `K` scripts run at different times ("start" and "kill" if I recall, I only play a sysadmin online), so do some research. – glenn jackman Jan 13 '21 at 02:58
  • Yeah they're run in alphabetical order. Putting that goodbye_message script just before halt (S89) still had it before a lot of the other shutdown messages. I think the correct course is to add the echo at the end of the halt script itself – Eliezer Miron Jan 13 '21 at 19:24