![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Background Process Shell Scripting | dhieraj | Shell Programming and Scripting | 3 | 04-12-2008 11:16 AM |
| How to include RETURN KEY with Background process "&" in Shell Script | racbern | Shell Programming and Scripting | 1 | 03-11-2008 03:30 AM |
| Facing issue in Solaris OS in crontab for running shell script | mabrar | Shell Programming and Scripting | 2 | 11-02-2007 02:32 AM |
| Background shell script | Moofasa | Shell Programming and Scripting | 5 | 05-12-2005 06:23 PM |
| capture the process id when starting a background process | jleavitt | Shell Programming and Scripting | 10 | 04-04-2002 05:04 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
|||
|
facing problem in starting a process in background using shell script.
hey all,
i am working on sun solaris machine and i want to start a process in background using shell script (actually i wanna start tomcat server using shell script). please dont tell me that append a & at last because this is not working in the shell script. i have also used nohup and redirected the output to /dev/null but all tries going into waste because every time the process is starting in forground and script hangs at that line help awaited. |
| Forum Sponsor | ||
|
|
|
|||
|
Yes, somebody has ever tried to start a process in the background. The problem is, it will foreground if it requires tty input. An interactive shell will thus foreground when it wants to read input. If you disable that, you can run it in the background just fine.
Code:
sh </dev/null & Servers usually have their own start-up scripts which often require root privileges. Depending on your architecture, look for something like /etc/init.d/tomcat (for a Debian-type system) or /etc/rc/tomcat or some such. |
|
|||
|
but the processes which i m trying to run by shell script doesnt require any input and still that processes are not going into background.
one more thing i want to say is that, these all processes are going into background successfully when i ran that processes at command prompt directly. the problem in coming when i m trying to run that processes through script. |
|
|||
|
If it helps you, here I paste one of my scripts where I launch a query script and send CR while it's running for my connection not to timeout. Hope it helps:
Code:
#!/bin/ksh
#set -x
# lanzamiento del script de consulta
/opt/bind/usr/sbin/loader.sh $1 $2 &
# Envio de un CR cada 3 segundos durante 1,5 minutos
# para evitar el corte por temporizacion
#
#
PID=$!
#echo $PID
cont=0
while [ `ps -p $PID|grep $PID|wc -l` -eq 1 -a $cont -lt 30 ]
do
echo
sleep 3
cont=`expr $cont + 1`
done
# Verificacion de si ha temporizado o no el proceso
#
#
if [ `ps -p $PID|grep $PID|wc -l` -eq 1 ]
then
kill -9 $PID
sleep 2
echo "ERROR: La consulta no se ha completado correctamente"
exit 1
else
echo "Consulta realizada con exito"
exit 0
fi
|
|
|||
|
thanx for the script!!!
as long as i understand, it seems that this is calling another script in background but i wanna ask one thing here is that this called script is an infinite script or it return after some time. and are you sure that this called script in going into background? one more thing, i think there can be difference in running these script on unix machine and solaris machine? is this true? reply awaited. |
|||
| Google The UNIX and Linux Forums |