Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I have the following cron job who goal is to show disk free on a server at 12:01 am each day. Also want to write a time/date stamp to the log, because we are wanting to watch disk size grow. However it isn't writing anything to the following df.log file at all.
You're missing the end backquote, but even if you put it in there before "-df" it is escaped by the preceding backslash. You may also need the full path to "date". This works for me:
Cron uses the delimiters to pass a literal "%" to date. You only see them when you run date on the command line, when you run it through cron they disappear. Without them you'll get errors out the wazoo from cron when it tries to run the command.
The weird thing is that it didn't write to df.log however it created the following file: 2016-03-04-08-33-33-df.log. I'm not sure why it didn't write to the df.log file Vs creating a new file.
it created the following file: 2016-03-04-08-33-33-df.log.
Good
Quote:
Originally Posted by JockVSJock
I'm not sure why it didn't write to the df.log file Vs creating a new file.
Because that's what you told it to do. What did you think "command > /root/output/df/$(date "+%Y-%m-%d-%H-%M-%S")-df.log" was supposed to do if not write the output of the command to a dynamic filename using the current system date/time???
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.