Re: Log date
- From: Nils Kassube <kassube@xxxxxxx>
- Date: Thu, 27 Mar 2008 21:01:54 +0100
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
--
ubuntu-users mailing list
ubuntu-users@xxxxxxxxxxxxxxxx
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
- Follow-Ups:
- Re: Log date
- From: Mario Frechette
- Re: Log date
- References:
- Log date
- From: Mario Frechette
- Re: Log date
- From: Nils Kassube
- Re: Log date
- From: Mario Frechette
- Log date
- Prev by Date: Re: Managed to install Ubuntu but a question about Alsa
- Next by Date: Firefox downloads JPEG instead of displaying
- Previous by thread: Re: Log date
- Next by thread: Re: Log date
- Index(es):
Relevant Pages
|