- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- How can I send to logfile based on 'date + %a' in ...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-11-2005 02:00 AM
тАО07-11-2005 02:00 AM
When I test at the command line -
/interface/test.sh > /interface/test.log.$(date +%a)
I end up with a log file called "/interface/test.log.Mon"
When I try to put this in cron, the log file gets created as "/interface.test.log." - it ignores the date portion. How can I get this to work the way I need it to?
Solved! Go to Solution.
- Tags:
- date
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-11-2005 02:21 AM
тАО07-11-2005 02:21 AM
Re: How can I send to logfile based on 'date + %a' in cron?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-11-2005 02:34 AM
тАО07-11-2005 02:34 AM
Re: How can I send to logfile based on 'date + %a' in cron?
As mentioned, cron is a sparse environment.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-11-2005 02:37 AM
тАО07-11-2005 02:37 AM
Re: How can I send to logfile based on 'date + %a' in cron?
/interface/test.sh > /interface/test.log.$(/sbin/date +%a)
UNIX because I majored in cryptology...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-11-2005 02:40 AM
тАО07-11-2005 02:40 AM
Re: How can I send to logfile based on 'date + %a' in cron?
try changing :
/interface/test.log.$(date +%a)
to:
/interface/test.log.$(/usr/bin/date +%a)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-11-2005 02:41 AM
тАО07-11-2005 02:41 AM
Re: How can I send to logfile based on 'date + %a' in cron?
/interface/test.sh > /interface/test.log.$(/usr/bin/date +%a)
The script is a generic ftp script that we want to use for several different systems, and we are trying to avoid making system specific changes to the script - we are passing parameters as needed from within cron on each system. We currently send to a specific log file, and I was just trying to make it so that I would have a weeks worth of logfiles to go back to in the event of problems, and also wouldn't have to worry about cleaning them up since they would be overwritten weekly.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-11-2005 03:05 AM
тАО07-11-2005 03:05 AM
Solutioninstead of /usr/bin/date or /sbin/date, just try putting in whatever the result of the command "which date" is. As far as avoiding hard-coding it for each machine type - well, just decide on a place for it to run from, and make symbolic links for the other machines. I've had to do this to handle differences between OSs before.
For a plan B - when I've had trouble with cron in the past (similar to what you're experiencing) sometimes I've had to resort to creating a script that has a "#!/bin/ksh" line at the top (to invoke a full ksh), and have the cron job run that script, instead of trying to run the whole command from within cron itself. Put your command with the full path in that new file, or set your environment variables to pick it up from either machine in the PATH variable.
HTH
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-11-2005 03:23 AM
тАО07-11-2005 03:23 AM
Re: How can I send to logfile based on 'date + %a' in cron?
Thanks....
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-11-2005 02:19 PM
тАО07-11-2005 02:19 PM
Re: How can I send to logfile based on 'date + %a' in cron?
Try replacing command with test.log.`date +%a`
To know the error in cron, i would suggest to log the error also. Add 2>>
~Pradeep.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-11-2005 10:44 PM
тАО07-11-2005 10:44 PM
Re: How can I send to logfile based on 'date + %a' in cron?
Then, each night at midnight, a single script runs that copies each log file to an /arch/logs directory, renaming the copy based on date, then purging the orginal.
It also does the same for other system log files (mail, syslog, etc) to keep them small.
Then finally, it deletes older log files from arch (I keep mine for months).
Advantage is, out on the system I don't have various collections of log files. I can easily locate the day's logs because the names are static, or go to /arch/logs to find the older stuff.