Reputation: 179
I have a script that tails a log file in the background and then redirects it to a file:
tail -f ~/dev/logs/*.log > $LOG 2>&1 &
LOG_PID=$!
Later on I kill it:
kill $LOG_PID
But it prints an untidy message to the console:
/Users/.../restart: line 47: 66634 Terminated: 15 tail -f ~/dev/logs/*.log > $LOG 2>&1s
How do I stop that message being printed?
Upvotes: 1
Views: 37
Reputation: 47956
You are redirecting both stdout and stderr into your log file (by redirecting stderr into stdout) - this is why you are seeing the Terminated
message. Since the error is actually written to stderr, by only redirecting stdout, you won't see that error log line.
Basically all you need to do is remove the section where you are redirecting stderr into stdout (2>&1
).
Upvotes: 3