I have a restart script that kills a process, starts the process, sleeps for a while, then kills the process again, and so on.
I want to be able to Strg + C the shell script when it's sleeping but still keep the created process around.
I tried this (simplified):
#!/bin/bash
while true; do
kill -SIGTERM $(pgrep foo)
(foo &)
sleep $((5*60*60))
done
However, the PPID of process f
So, we can execute simultaneous command in the shell by appending '&' to the end of the line and then executing 'wait' to wait for the commands to finish. Is it possible for functions?
From what I understand, SIGKILL cannot be caught. This would imply that a process does not have time to kill it's children before the OS destroys it. This can be demonstrated with a shell script.
#!
how to run a run a shell script in background even if i exit the terminal or logout,
the process end only when i kill with command kill
I am trying to write a simple Korn shell script to execute a loading process. The process occasionally runs into connectivity issues, so I need to kill it if it runs too long.
I have been trying the following code:
#!/usr/bin/ksh
. /home/dw/script/load.ksh &
LOADPID=$!
sleep 100
kill $LOADPID
Unfortunately, the kill command does not kill the process - am I missing something?
When I run this command:
ps aux|awk {'print $1,$2,$3,$11'}
I get a listing of the user, PID, CPU% and the actual command.
I want to pipe all those listings into a shell script to calculate the CPU% and if greater than, say 5, then to kill the process via the PID.
I tried piping it to a simple shell script, i.e.
ps aux|awk {'print $1,$2,$3,$11'} | ./myscript
where the content of my script is
I have the following ksh script:
sqlplus usr1/pw1@DB1 @$DIR/a.sql $1 &
sqlplus usr2/pw2@DB2 @$DIR/b.sql $1 &
wait
echo "Done!"
Where $DIR is a variable with the absolute path where a.sql and b.sql are.
For some time, I've been running this script daily and it works fine.
I have a shell script called run.sh. In it, I may call other shell scripts like:
./run_1.sh
./run_2.sh
.........
If I call the script by ./run.sh, I have found actually it will invoke different tasks inside the script sequentially with different PIDs(i.e., run_1.sh will be a task and run_2.sh will be another task).
I'm trying to spawn an ssh from my bash profile script that runs in the background for connection sharing (via its control socket).