How to: Run a shell script with nohup command

Posted on in Categories , , last updated October 16, 2007

Q. I’d like to run a command or shell script immune to hangups, with output to a non-tty or file. How do I use nohup command to run script called ~/utils/backup upload?

A. nohup is a Unix command that is used to run another command while suppressing the action of the HUP (hangup) signal, enabling the command to keep running after the user who issues the command has logged out. It is most often used to run commands in background as daemons. Output that would normally go to the terminal goes to a file called nohup.out if it has not already been redirected.

Run a script with nohup command

Type the command as follows to run a script called ~/utils/backup with ‘upload’ as argument to script:
$ nohup ~/utils/backup "upload" &

Linux / UNIX killing a process and restarting the same

Posted on in Categories , last updated July 16, 2007

Q. How do I kill a process called inetd or foo and restart the same so that configuration file get updated?

A. Both UNIX and Linux supports POSIX reliable signals and POSIX real-time signals. Each signal has a current disposition, which determines how the process behaves when it is delivered the signal.

Generally following command is used
kill -1 process-pid

First get pid of inetd:
ps -e | grep inetd
Now force read inetd.conf:
kill -1 xinetd-pid

You can also use pkill command used to send signals. The pkill command allows the use of extended regular expression patterns and other matching criteria.
pkill -HUP process-name

Make syslog reread its configuration file
# pkill -HUP syslogd

Make xinetd reread its configuration file
# pkill -HUP inetd