- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: cron help
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
Forums
Discussions
Discussions
Discussions
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
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
06-02-2006 07:26 AM
06-02-2006 07:26 AM
cron help
But since the log grows over time I would like to create a separate output for each day
ex-
current entry:
05,25 * * * * exec ksh -c '. ${HOME}/.profile;~/parse.sh >> /log/parse.log'
I would like to have
05,25 * * * * exec ksh -c '. ${HOME}/.profile;~/parse.sh > /log/parse.log_06022006'
Can anyone please help me.
-Pat
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-02-2006 07:33 AM
06-02-2006 07:33 AM
Re: cron help
05,25 * * * * exec ksh -c '. ${HOME}/.profile;~/parse.sh > /log/parse.log_`date +%m%d%Y`'
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-02-2006 07:43 AM
06-02-2006 07:43 AM
Re: cron help
Don't forget to redirect with ">>", otherwise the file will be recreated every-time the cronjob starts.
05,25 * * * * exec ksh -c '. ${HOME}/.profile;~/parse.sh >> /log/parse.log_`date +%m%d%Y`'
Darrel
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-05-2006 02:10 AM
06-05-2006 02:10 AM
Re: cron help
and even more - don't forget - as the previous poster, that a %-sign in a crontab-entry has a special meaning and must be escaped.
I think in HP-UX you have to write two percent signs:
05,25 * * * * exec ksh -c '. ${HOME}/.profile;~/parse.sh >> /log/parse.`date +%%m.%%d.%%y`.log
mfG Peter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-05-2006 02:42 AM
06-05-2006 02:42 AM
Re: cron help
#!/usr/sbin/sh
DATE=`date +%Y%m%d`
cp /log/parse.log /log/parse.${DATE}.log
cat /dev/null > /log/parse.log
Have the script run just before midnight, so that the date in the filename matches the date of the log's contents.
PCS
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-05-2006 04:58 AM
06-05-2006 04:58 AM
Re: cron help
Personally, I'd put the log inside the script:
Date=$(date +"%y%m%d")
Log=/log/parse_log_${Date}
(
commands to be executed
) >> ${Log} 2>&1
that way the crontab stays a little cleaner...
Doug
------
Senior UNIX Admin
O'Leary Computers Inc
linkedin: http://www.linkedin.com/dkoleary
Resume: http://www.olearycomputers.com/resume.html