- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- timestamp script
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-02-2009 09:01 AM
тАО07-02-2009 09:01 AM
This text.log file keeps updated with the new one and doesnot gets appended.
So will need a script which will check if the file is new then goes ahead with rest of the action.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-02-2009 09:34 AM
тАО07-02-2009 09:34 AM
SolutionTHis is one way to do what you seek:
# cat ./watch
#!/usr/bin/sh
LOGF=/tmp/mylog
REFF=/tmp/myref
touch ${LOGF} ${REFF}
while true
do
if [ "$LOGF" -nt "${REFF}" ];then
echo "${LOGF} has been updated"
touch -cmr ${LOGF} ${REFF}
fi
sleep 30
done
...You can play with this concept by running the script in the background and 'touch'ing the LOGF file to update it.
Adjust the script's wleep time to you needs.
Regards!
...JRF...
- Tags:
- Touch
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-03-2009 06:28 AM
тАО07-03-2009 06:28 AM
Re: timestamp script
James has a good idea.
I have a question though and that is how often is the log file replaced? Is it a known time interval or random interval?
If it is random what is the shortest time?
You want to set your sleep time shorter then the shortest time interval but not so short that it is running all the time. That can hog CPU time.
Is this being run from a terminal (telnet) session or in the background? If you are running this in the background from a telnet session you may want to add a 'trap' statement (example trap exit 1 2 3 15) in the beginning to stop the script if the telnet session terminates.
-Ken
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-03-2009 07:26 AM
тАО07-03-2009 07:26 AM
Re: timestamp script
> Ken: If you are running this in the background from a telnet session you may want to add a 'trap' statement (example trap exit 1 2 3 15) in the beginning to stop the script if the telnet session terminates.
This doesn't matter to the job in the background if it was started with 'nohup'. In that case, the shell will terminate and any running children will be inherited by the 'init' daemon making 'init' their parent process.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-03-2009 08:08 AM
тАО07-03-2009 08:08 AM
Re: timestamp script
find $DATA -depth -type f \( -ctime -1 -o -mtime -1 \) -print > $LIST
That will pick up files that are new.
Then process the LIST and take whatever action you need.
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-03-2009 09:31 AM
тАО07-03-2009 09:31 AM
Re: timestamp script
@ SEP: If you read the OP's description it notes, "I need to run this script in such a way that it runs only if text.log is a new file.".
The interest is in ONE particular file, not a list of files that have been updated. The goal is for the monitoring script to be awaken when that file changes; to note that change event; and sleep until another change occurs. Subsequent changes could be seconds, minutes, hours or days later. Your suggestion doesn't help that objective.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-03-2009 10:27 PM - edited тАО10-01-2011 07:45 PM
тАО07-03-2009 10:27 PM - edited тАО10-01-2011 07:45 PM
Re: timestamp script
>JRF: touch ${LOGF} ${REFF}
That's: touch -r ${LOGF} ${REFF}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-06-2009 07:06 AM
тАО07-06-2009 07:06 AM
Re: timestamp script
> Dennis: touch -r ${LOGF} ${REFF}
Yes, good point, Dennis. I didn't mean to update the timestamp of the ${LOGF} at startup. Thanks.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-12-2009 09:17 AM
тАО07-12-2009 09:17 AM