I'm running Rasbpian on my Pi, and I have a script in /etc/rc0.d (or more precisely, a symlink to /etc/init.d/myscript.sh) that does some GPIO output to notify the user that power can be shut off.
If I run sudo shutdown -h now, the script runs, and the system goes down.
If I run sudo shutdown now, the script does not run, but the system goes down.
I cannot find any documentation that states what should really happen when running shutdown now with no other arguments.
What difference does the -h make in this case? Does running shutdown now really not invoke runlevel 0?
Update: I found this doc (unixhelp.ed.ac.uk), saying that the default behaviour with no arguments is to go to runlevel 1. But I have a script in /etc/rc1.d, too, that does not run on shutdown.
As requested, here are the first few lines from last -x (the arrows are mine):
pi pts/3 vidar-ramdals-ma Fri Jan 9 18:07 still logged in
runlevel (to lvl 2) 3.12.28+ Fri Jan 9 18:04 - 18:07 (00:02)
reboot system boot 3.12.28+ Fri Jan 9 18:04 - 18:07 (00:02)
shutdown system down 3.12.28+ Fri Jan 9 18:04 - 18:04 (00:00)
runlevel (to lvl 0) 3.12.28+ Fri Jan 9 18:04 - 18:04 (00:00) <- shutdown -h now
pi pts/3 vidar-ramdals-ma Fri Jan 9 18:02 - down (00:01)
runlevel (to lvl 2) 3.12.28+ Fri Jan 9 18:01 - 18:04 (00:02)
reboot system boot 3.12.28+ Fri Jan 9 18:01 - 18:04 (00:02)
pi pts/3 vidar-ramdals-ma Fri Jan 9 17:57 - crash (00:04) <- shutdown now
pi pts/3 vidar-ramdals-ma Fri Jan 9 01:30 - 01:34 (00:03)
pi pts/3 vidar-ramdals-ma Fri Jan 9 01:29 - 01:29 (00:00)
runlevel (to lvl 2) 3.12.28+ Fri Jan 9 01:23 - 18:01 (16:38)
reboot system boot 3.12.28+ Fri Jan 9 01:23 - 18:04 (16:41)
The runlevel (to lvl 0) line appears after I did shutdown -h now, while the crash line is from shutdown now. Does shutdown now cause a "crash" which prevents it from running init scripts?
last -xfor us? Maybe it's switching to yet a different runlevel. (I have a vague recollection it was runlevels, single user mode, in slackware?)last -x? After reboot, or before runningsudo shutdown now? I'll try when I get home this afternoon. And, BTW, isn't runlevel1single user mode? wiki.debian.org/RunLevellastlooks at the history of your logins, reboots and runlevel changes, so it should tell you what runlevel yourshutdownputs you in.