Hi
I have a bash script that I need to run both interactivly and non-interactivly (ie via crond or using '&').
This script echo's my lovely junk to the terminal if run interactivly, or to a file if run via crond.
I use: (Which works fine!!)
if [ -z $(tty) ]; then
exec > the_file 2>&1
fi
However I need the bash script to also be able to completly detach from the tty/pts session when run in the background ... ie ./script.sh & Which currently it is still aware that it has a terminal attaxched and displays the results to the tty/pts terminal
Any ideas how i can convince the script it is NOT running interactivly when it is run using '&' ?
Many Thanks
Kul
I have a bash script that I need to run both interactivly and non-interactivly (ie via crond or using '&').
This script echo's my lovely junk to the terminal if run interactivly, or to a file if run via crond.
I use: (Which works fine!!)
if [ -z $(tty) ]; then
exec > the_file 2>&1
fi
However I need the bash script to also be able to completly detach from the tty/pts session when run in the background ... ie ./script.sh & Which currently it is still aware that it has a terminal attaxched and displays the results to the tty/pts terminal
Any ideas how i can convince the script it is NOT running interactivly when it is run using '&' ?
Many Thanks
Kul