How to zero out a logfiles

Ladner, Eric (Eric.Ladner) Eric.Ladner at chevrontexaco.com
Tue May 25 05:25:34 EDT 2004


How about:

sudo cp /dev/null /var/adm/logfile

That avoids the whole problem with shell redirection and all.  The
problem with 'sudo echo > /var/adm/logfile' is the way that it gets
executed in the shell.  It really gets executed like this:

[ Sudo echo  (echo runs with root privleges, whoopie) ] then YOUR shell
tries to output that to the file /var/adm/logfile.  Since YOU can't
write the file, it gives you the permission denied message.

Eric


-----Original Message-----
From: sudo-users-bounces at sudo.ws [mailto:sudo-users-bounces at sudo.ws] On
Behalf Of Stephen Carville
Sent: Wednesday, March 31, 2004 7:53 PM
To: Sudo Users
Subject: Re: How to zero out a logfiles


On Wednesday March 31 2004 01:16 pm, Jim Horwath wrote:
> Hi all,
>
> I have been using sudo for a few months and I'm still learning the 
> ropes.  I need to zero a logfile with sudo, but I can't get the '>' 
> syntax just right.  I tried to search the archives but didn't find any

> hints.  I can't be the first (or last) person who wants to do this.
>
> For example:
>
> sudo echo > /var/adm/logfile
>
> or something similiar

The only way I know how is:

echo | sudo tee /var/log/admfile

-- 
Stephen Carville
UNIX and Network Administrator
DPSI
310-342-3602
stephen at totalflood.com
--
If you have been voting for politicians who promise to give you goodies
at 
someone else's expense, then you have no right to complain when they
take 
your money and give it to someone else, including themselves.
      --Thomas Sowell (1992)
____________________________________________________________ 
sudo-users mailing list <sudo-users at sudo.ws>
For list information, options, or to unsubscribe, visit:
http://www.sudo.ws/mailman/listinfo/sudo-users






More information about the sudo-users mailing list