
07-01-2009
|
|
Moderator
|
|
|
Join Date: Feb 2005
Location: Boston, MA
Posts: 5,121
|
|
Quote:
Originally Posted by pravfraz
hi folks,
In the following code, logfile remains empty.
Code:
log_file="/u/Sc/prav.log.$mon$day"
ps -ef | grep "myprocess"| awk -v logfile=$log_file '{
system("date >> logfile")
}'
can u please help as how to log the date to that logfile.
thanks in advance!
|
- why do you need awk? Cannot you use file redirection instead?
- If you do need awk, why do you need 'grep'? Awk can do it all.
- ps -ef | awk -v logfile="${log_file}" '/myprocess/{cmd="date >> " logfile; system(cmd); close(cmd)}"
|