LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 11-28-2012, 07:29 AM   #1
depam
Member
 
Registered: Sep 2005
Posts: 861

Rep: Reputation: 30
Need help on converting date time format in text file and triggering action


Hi,

Need help to create a script to get date format value from text file. I have a log text file which has the below date time value on every line:

Wed Nov 21 11:04:10 GMT 2012 - SOMETEXT|TEXT1|TEXT2|TEXT3|etc....etc

I want to somehow find a way to trigger a action using the following condition:

1.) Check every 30 minutes for variable showing "NOT RESPONDING" from the last time I triggered the job.

But I am thinking on how to convert the above time into something that I can use an operator "now is equal or less than".

Can someone please help to construct this for me? I am a newbie on scripting.
 
Old 11-28-2012, 08:46 AM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Quote:
Originally Posted by depam View Post
Need help to create a script
What you need is to separate your questions and match each one to a solution. When you have got it all, then you glue it together as a script.


Quote:
Originally Posted by depam View Post
Check every 30 minutes for
That's a cron job. Show us how the cron entry would read if the script was called "/usr/local/bin/check".


Quote:
Originally Posted by depam View Post
variable showing "NOT RESPONDING"
That's grep. Show us how the grep line would look like.


Quote:
Originally Posted by depam View Post
how to convert the above time into something that I can use an operator "now is equal or less than".
That's epoch. Read 'man date' and show us:
- how you display time in epoch format,
- how you display the time it is now in epoch format,
- how you display the time 30 minutes ago in epoch format.


Quote:
Originally Posted by depam View Post
I am a newbie on scripting.
All the more reason to put in a wee bit more effort IMHO. Also, as you seem to be working with Voice over IP and Short Message Services, it wouldn't harm to check if interfaces, tools or 3rd party applications exist that help you with diagnosing and reporting problems.
 
Old 11-28-2012, 09:14 AM   #3
depam
Member
 
Registered: Sep 2005
Posts: 861

Original Poster
Rep: Reputation: 30
Thanks.

Yes you are correct this can be achieved by cron. Sorry for the confusion. What I am more concerned about is the date manipulation on changing that specific date format on a text file to an epoch time and pass a condition that if certain values with the timestamp on that text file is 30 minutes kess than the current date and time, it will trigger something.

To make it easy, i want that value in text to be converted and compared with the current system time to create a condition. Thanks.
 
Old 11-28-2012, 09:46 AM   #4
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
My reply addresses that already. Return what I asked for and you'll see.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Help, converting date format in a comma separated field! mgsmith7475 Programming 2 04-09-2010 11:34 AM
Converting a date in MySQL format to human readable in Perl resetreset Programming 7 02-11-2009 07:14 AM
Converting PDF to text, rtf doc format saurya_s Linux - Software 2 06-16-2005 01:48 PM
In C, converting time format Miaire Programming 4 02-03-2005 12:25 AM
loading data from a flat file with a date and time having a different format spyghost Programming 2 11-02-2003 04:40 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 07:42 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration