Copy the messages file via cron

Post new topic   Reply to topic    DD-WRT Forum Index -> Generic Questions
Author Message
Frakko
DD-WRT Guru


Joined: 06 May 2016
Posts: 518

PostPosted: Sun Jan 15, 2017 16:40    Post subject: Copy the messages file via cron Reply with quote
I applied two commands in administration-> cron:

1 * * * * * root cp /var/log/messages /mnt/sda1/messages_"% date"
1 * * * * * root del /var/log/messages

It seems not to work. I would copy once a minute the messages file and delete it.
If you want to apply the data to the name of the file I tried, unsuccessfully, to use the command "date."
Thank you.
Sponsor
mwchang
DD-WRT Guru


Joined: 26 Mar 2013
Posts: 1855
Location: Hung Hom, Hong Kong

PostPosted: Fri Sep 15, 2017 15:04    Post subject: Re: Copy the messages file via cron Reply with quote
Frakko wrote:
....
1 * * * * * root cp /var/log/messages /mnt/sda1/messages_"% date"
....
If you want to apply the data to the name of the file I tried, unsuccessfully, to use the command "date."
Thank you.

You should have "`" (next to <1>) instead of '"'! "``" executes a command. "xxx" just represents a string.

BTW, some Google keywords for you:
https://www.google.com.hk/search?q=bash+scripting+%60date%60
And this:
https://www.google.com.hk/search?q=bash+scripting+filename+with+date&oq=bash+scripting+filename+with+date

_________________
Router: Asus RT-N18U (rev. A1)

Drink, Blink, Stretch! Live long and prosper! May the Force and farces be with you!

Facebook: https://www.facebook.com/changmanwai
Website: https://sites.google.com/site/changmw
SETI@Home profile: http://setiathome.berkeley.edu/view_profile.php?userid=211832
GitHub: https://github.com/changmw/changmw
Display posts from previous:    Page 1 of 1
Post new topic   Reply to topic    DD-WRT Forum Index -> Generic Questions All times are GMT

Navigation

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum