I am aware that I can log using tee
But I want to log from inside my script, at the same time display the content on the stdout
.
Example, my code looks something like this:
names=$(print("name1 name2 name3 name4"))
for name in names
do
echo "Current Name: " $name
related_job= ps -ef | grep $name | awk '{print $9}' >> File.dat
echo "related job: " $related_job
done
Now, this block will certainly echo
at stdout, but I even want to log this to a log file, say script_name.log
.
Also, I am calling the script through a scheduler and sue to come constraint I can't use script_name | tee log_file
. I can just call the script by the script name.
What could be the solution to this?
tee
has no problem working within a script. – SparedWhisle Oct 06 '15 at 05:22