How can I add a logfile line to the following bash file?
#!/bin/sh if ps x |grep -v grep |grep -c cccam_2.3.2 >/dev/null then echo "cccam... ok" else echo "cccam... restarting" /var/bin/cccam_2.3.2 & fi
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.Sign up to join this community
I believe you want to use
logger command like here:
root@dst:~# logger "Hello log stuff." root@dst:~# grep Hello /var/log/messages Jan 27 16:32:42 dst root: Hello log stuff.
man logger provides nice options too.
I think you can also add -x with shell script and redirect that to a logfile. I use it to log and debug few shell scripts
Something like this
sh -x your_script.sh 2> logfile.log