Archive forSeptember, 2008

Status of dd command…

setup your dd as normal:

dd if=whatever.dd of=/dev/sda &

pkill -USR1 ^dd$

or watch it

watch -n5 — pkill -USR1 ^dd$

Comments off

svc .. svstat .. /service .. huh?!?!?!?

The svc program
svc controls services monitored by supervise.
Interface

svc opts services

opts is a series of getopt-style options. services consists of any number of arguments, each argument naming a directory used by supervise.

svc applies all the options to each service in turn. Here are the options:

* -u: Up. If the service is not running, start it. If the service stops, restart it.
* -d: Down. If the service is running, send it a TERM signal and then a CONT signal. After it stops, do not restart it.
* -o: Once. If the service is not running, start it. Do not restart it if it stops.
* -p: Pause. Send the service a STOP signal.
* -c: Continue. Send the service a CONT signal.
* -h: Hangup. Send the service a HUP signal.
* -a: Alarm. Send the service an ALRM signal.
* -i: Interrupt. Send the service an INT signal.
* -t: Terminate. Send the service a TERM signal.
* -k: Kill. Send the service a KILL signal.
* -x: Exit. supervise will exit as soon as the service is down. If you use this option on a stable system, you’re doing something wrong; supervise is designed to run forever.

The svscan program
svscan starts and monitors a collection of services.
Interface
svscan starts one supervise process for each subdirectory of the current directory, up to a limit of 1000 subdirectories. svscan skips subdirectory names starting with dots. supervise must be in svscan’s path.

svscan optionally starts a pair of supervise processes, one for a subdirectory s, one for s/log, with a pipe between them. It does this if the name s is at most 255 bytes long and s/log exists. (In versions 0.70 and below, it does this if s is sticky.) svscan needs two free descriptors for each pipe.

Every five seconds, svscan checks for subdirectories again. If it sees a new subdirectory, it starts a new supervise process. If it sees an old subdirectory where a supervise process has exited, it restarts the supervise process. In the log case it reuses the same pipe so that no data is lost.

svscan is designed to run forever. If it has trouble creating a pipe or running supervise, it prints a message to stderr; it will try again five seconds later.

If svscan is given a command-line argument, it switches to that directory when it starts.

The svstat program
svstat prints the status of services monitored by supervise.
Interface

svstat services

services consists of any number of arguments, each argument naming a directory. svstat prints one human-readable line for each directory, saying whether supervise is successfully running in that directory, and reporting the status information maintained by supervise.

The supervise program
supervise starts and monitors a service.
Interface

supervise s

supervise switches to the directory named s and starts ./run. It restarts ./run if ./run exits. It pauses for a second after starting ./run, so that it does not loop too quickly if ./run exits immediately.

If the file s/down exists, supervise does not start ./run immediately. You can use svc to start ./run and to give other commands to supervise.

supervise maintains status information in a binary format inside the directory s/supervise, which must be writable to supervise. The status information can be read by svstat.

supervise may exit immediately after startup if it cannot find the files it needs in s or if another copy of supervise is already running in s. Once supervise is successfully running, it will not exit unless it is killed or specifically asked to exit. You can use svok to check whether supervise is successfully running. You can use svscan to reliably start a collection of supervise processes.

Comments off

Linux auto reboot after kernel panic

By default after a kernel panic Linux just sits there and waits for a user to hit the restart button.

That can be a bad thing if it’s a remote server.

To check if its enabled try this:
Code: cat /proc/sys/kernel/panic

0

The returned 0 is the time the kernel will wait before it reboots. If it is 0 or lower, it won’t reboot by itself.

To set the kernel to reboot do this command:

# echo “5″ > /proc/sys/kernel/panic

Where 5 is replaced with the number of seconds to wait till reboot after a kernel panic.

To check the time was set right do this:
Code: cat /proc/sys/kernel/panic

5

To make it more permanent do this:

# echo “kernel.panic=5″ >> /etc/sysctl.conf

Adding the following to your kernel parameters in your bootloaders configuration might also help:

panic=5

NOTE: Substitute 5 with the number of seconds to wait till reboot after a kernel panic.

Retrieved from “http://gentoo-wiki.com/TIP_Kernel_Panic_Reboot”

Comments off