Q:

reboot Linux box from user space

I need to reboot a Linux box from a user space process. I want to have the following behavior:

sync file systems
not attempt to gracefully stop processes, go to runlevel 5/6, etc., for I assume things are bad and that would fail

Can those requirements be achieved together at all? 
I was planning to write a 'b' into proc/sysrq-trigger. Is there a better way? (No, that won't give me sync.)
Thanks!

A:

I'm assuming you have root.

the sysrq-trigger thing is fine, you just have to echo 's' a couple times into it first, which is an "Emergency Sync".
You can also check out the '-n' option to shutdown(8). That's a canned way to do what you want. It just sends SIGTERM, SIGKILL, syncs and shuts down or reboots (-h or -r option.)

Hope that helps.

A:

Well, do sync(1), kill -1, sync again, kill -9 -1, sync, poweroff -f.
That should do the trick, I guess!

