Create log file

Solved
yacleouf Posted messages 461 Status Member -  
yacleouf Posted messages 461 Status Member -
Hello,

I’m coming back once again to the forum to ask a question about the shell that I absolutely know nothing about…

My problem may seem easy to you… not for me :-)

so here is this small shell program I have:

#!/bin/bash
workFolder=$(readlink -f $(dirname $0))
touch Log-'date +%Y%m%d'.log
LOGFILE=Log-'date +%Y%m%d'.log
find /var/ftp/TestArchivage/Archive -mtime +60 -type f -name "*.xml" -exec rm -f {} +

I tried these two solutions

$workFolder"/"$LOGFILE tee -a 2>&1 $workFolder"/"$LOGFILE

But neither works and each time it tells me Permission denied,
I tried to chmod 777 on the log file but still nothing is written inside…

A little help wouldn’t be refused ^^

Thanks in advance!

Configuration: VGN-cs21S, Windows 7 Professional 64-bit

--
Google is your friend!

2 answers

zipe31 Posted messages 34620 Registration date   Status Contributor Last intervention   6 501
 
Hello,

find /var/ftp/TestArchivage/Archive -mtime +60 -type f -name "*.xml" -exec rm -f {} + > ${workFolder}/${LOGFILE} 2>&1


--
Zen my nuggets ;-)
Take a step for the environment, close your windows and adopt a penguin.
0
yacleouf Posted messages 461 Status Member 39
 
Hi zipe31,

I just tried what you bolded, but nothing works...

Here is an excerpt of a log line for reference:
- rw-r--r--. 1 root root 0 Jun 17 17:24 Log-20130617.log

My log file isn’t filling up...

P.S. I do have old files dating from last year.

--

Google is your friend!
0
zipe31 Posted messages 34620 Registration date   Status Contributor Last intervention   6 501
 
Does the following command display something at least?

find /var/ftp/TestArchivage/Archive -mtime +60 -type f -name "*.xml" -exec echo "rm -f {}" +
0
yacleouf Posted messages 461 Status Member 39
 
Yes, it listed all the files that meet the condition!
0
zipe31 Posted messages 34620 Registration date   Status Contributor Last intervention   6 501
 
And now by adding the redirect, does the log file fill up?
0
yacleouf Posted messages 461 Status Member 39
 
after several tests I must misplace "the delete request" because nothing is deleted..
On the other hand the file fills up well.
0
zipe31 Posted messages 34620 Registration date   Status Contributor Last intervention   6 501
 
Attention, in my last message, I added a "echo" to see what the command was doing and to guard against accidental deletion ;-(

That’s actually a good habit to adopt, especially with the "rm" command ;-\

You can also add the "-v" option to the "rm" command to make it more verbose...
0