Log date
Mario Frechette
mario at technicite.ca
Thu Mar 27 22:23:30 UTC 2008
Nils Kassube a écrit :
> Mario Frechette wrote:
>
>> but what I would like is to create a log file with a date in the name
>> of the file that would look like ( backup.log.`date +%d%m%y`) format
>> or anything near that
>> I succeded to create a file named backup.log in the /home DIR
>>
>> but how to do that in a bash script ?
>>
>
> A bash script is more or less only a sequence of the commands you can run
> on the command line. Therefore your filename would be made like you wrote
> above. Then you have to redirect the output of your commands inside the
> script to that file. That would be something like this:
>
> #!/bin/bash
> log=$(date "+backup.log.%d%m%y")
> echo "Starting backup $(date)"
> somecommand >>$log 2>&1
> anothercommand >>$log 2>&1
> echo "Backup finished $(date)" >>$log
>
> Both the output and error output of the commands are sent to the same log
> file.
>
>
> Nils
>
>
Thanks that worked great
Merci !
Mario
--
Mario Fréchette
Technicité
988 des Grives
Victoriaville
G6T1E8
819-740-0554
mario at technicite.ca
More information about the ubuntu-users
mailing list