One log file

This commit is contained in:
ssamson-tis 2015-07-09 10:42:47 +02:00
parent a555b5d55c
commit 2fb2166585
2 changed files with 8 additions and 10 deletions

View File

@ -15,8 +15,7 @@ user="root"
name=`basename $0` name=`basename $0`
pid_file="/var/run/$name.pid" pid_file="/var/run/$name.pid"
stdout_log="/var/log/$name.log" logfile="/var/log/$name.log"
stderr_log="/var/log/$name.err"
get_pid() { get_pid() {
cat "$pid_file" cat "$pid_file"
@ -34,13 +33,13 @@ case "$1" in
echo "Starting $name" echo "Starting $name"
cd "$dir" cd "$dir"
if [ -z "$user" ]; then if [ -z "$user" ]; then
sudo $cmd >> "$stdout_log" 2>> "$stderr_log" & sudo $cmd >> "$logfile" 2>&1 &
else else
sudo -u "$user" $cmd >> "$stdout_log" 2>> "$stderr_log" & sudo -u "$user" $cmd >> "$logfile" 2>&1 &
fi fi
echo $! > "$pid_file" echo $! > "$pid_file"
if ! is_running; then if ! is_running; then
echo "Unable to start, see $stdout_log and $stderr_log" echo "Unable to start, see $logfile"
exit 1 exit 1
fi fi
fi fi

View File

@ -15,8 +15,7 @@ user="root"
name=`basename $0` name=`basename $0`
pid_file="/var/run/$name.pid" pid_file="/var/run/$name.pid"
stdout_log="/var/log/$name.log" logfile="/var/log/$name.log"
stderr_log="/var/log/$name.err"
get_pid() { get_pid() {
cat "$pid_file" cat "$pid_file"
@ -34,13 +33,13 @@ case "$1" in
echo "Starting $name" echo "Starting $name"
cd "$dir" cd "$dir"
if [ -z "$user" ]; then if [ -z "$user" ]; then
sudo $cmd >> "$stdout_log" 2>> "$stderr_log" & sudo $cmd >> "$logfile" 2>&1 &
else else
sudo -u "$user" $cmd >> "$stdout_log" 2>> "$stderr_log" & sudo -u "$user" $cmd >> "$logfile" 2>&1 &
fi fi
echo $! > "$pid_file" echo $! > "$pid_file"
if ! is_running; then if ! is_running; then
echo "Unable to start, see $stdout_log and $stderr_log" echo "Unable to start, see $logfile"
exit 1 exit 1
fi fi
fi fi