Date check script (noob)

Thread Tools Search this Thread
# 1  
Date check script (noob)


I've been given the task of checking the date of expiration dates and notify when the date is 30 days away from expiration.

As stated in the Title, I'm very new to this, I did a good bit of work over the last two days to only find out I was going down the wrong path.

I'm not expecting anyone to do my work for me, just a nudge in the right direction would be great. I'm sure someone will write it up exactly but.. you get the picture Smilie I want to learn not just copy and paste.

>cat list

Valid from: Tue Dec 06 13:35:32 EST 2011 until: Thu Dec 06 13:35:32 EST 2012
Valid from: Tue Dec 06 13:35:34 EST 2011 until: Thu Dec 06 13:35:34 EST 2012
Valid from: Tue Dec 06 13:35:34 EST 2011 until: Thu Dec 06 13:35:34 EST 2011

I can say, NOT knowing every command and all of the ways to use them is an issue but I guess it's something you pick up over time.

I am now on to trying a new approach with this...

Using this command is giving me the exact day number and I'm thinking this might be the best way to do it?
 >date +%j

So if there was a way I could convert the "until: Thu Dec 06 13:35:34 EST 2011" portion to the +%j format, it might make it easier, no? If I can see that there is less than 30 days difference between the cur_date: xxx and exp_date: xxx it would be a bit easier?

Any help is appreciated,

Thank you

Moderator's Comments:
Mod Comment Please use

code tags!
# 2  
Please state what Operating System and version you have and what Shell you prefer. With anything to do with "date" the solution will depend on whether you have the GNU version of the "date" command.
In this case it will also depend on whether you can plan for implementation in 30 days time.
# 3  
Hello, sorry about that

SunOS 5.10 Generic_142900-01 sun4v sparc SUNW,Sun-Blade-T6300


# 4  
System design problem.
Any chance of intercepting the process which writes these log entries?
If it can calculate 12 months in advance, can it calculate 11 months in advance (and write a timestamp file in a machine-readable format)?

Last edited by methyl; 12-21-2011 at 03:31 PM..

Previous Thread | Next Thread
Thread Tools Search this Thread
Search this Thread:
Advanced Search

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell script to check current date file is created and with >0 kb or not for multiple directories

Hi All, I am new in scripting and working in a project where we have RSyslog servers over CentOS v7 and more than 200 network devices are sending logs to each RSyslog servers. For each network devices individual folders create on the name of the each network devices IP addresses.The main... (7 Replies)
Discussion started by: Pinaki
7 Replies

2. UNIX for Dummies Questions & Answers

I need a Script to read Log string and check date at the same time

I need to check 1 log file, which is logging: 2014-08-18T09:10:39+02:00 user: XXXXX START FEATURE 2014-08-18T09:10:39+02:00 user: XXXXX FINISH FEATURE I first need to check that the START FEATURE starts and finish on the same time/date for the same user, which is different each time START... (2 Replies)
Discussion started by: TheBest43
2 Replies

3. UNIX for Dummies Questions & Answers

Help in script to check file name with todays date

I am trying to include a snippet in my script to check if the file created is having today's date. eg: File name is : ABC.YYYYMMDD-nnn.log The script should check if 'YYYYMMDD' in the above file name matches with today's date. Can you please help me in achieving this. Thanks in advance!! (5 Replies)
Discussion started by: kiran1112
5 Replies

4. Shell Programming and Scripting

Create a Date Check Script

I have about 100 Linux servers running in Amazon EC2 (CentOS 6 based) and I need to run a 'date' command against all of them. Rather than logging into each individual server via 'ssh' and running the 'date' command, can someone please help me with how something like this can be scripted? I... (6 Replies)
Discussion started by: cmennens
6 Replies

5. Shell Programming and Scripting

Perl code to check date and check files in particular dir

Hi Experts, I am checking how to get day in Perl. If it is “Monday” I need to process…below is the pseudo code. Can you please prove the code for below condition. if (today=="Monday" ) { while (current_time LESS THAN 9:01 AM) ... (1 Reply)
Discussion started by: ajaypatil_am
1 Replies

6. Shell Programming and Scripting

Please help I want script to check filename, size and date in specify path.

Please help, I want script to check filename, size and date in specify path. I want output as: DATE: YYYYMMDD HH:MM ------------------------------------------------ fileA,filesize,yyyy mm dd HH:MM fileA,filesize,yyyy mm dd HH:MM fileA,filesize,yyyy mm dd HH:MM fileA,filesize,yyyy mm dd... (1 Reply)
Discussion started by: akeji
1 Replies

7. Shell Programming and Scripting

Script to check file with previous date

Hi all,I need your help to create the script.I need a script to check the ZIP file at network location with yesterday date name. ZIP file creation date is current date, but name of the zip file is previous date. for example file name "" created today 201102017.I just want to return the... (1 Reply)
Discussion started by: deepaksingla
1 Replies

8. Shell Programming and Scripting

Shell Script to compare files, check current date and count

Hello - I have written the following basic shell script to count files, compare files and look for a particular strings in a file. Problem 1: How do I define more than 1 file location? #!/bin/bash #this is a test script FILES=$(ls /home/student/bin/dir1, home/student/bin/dir2)... (0 Replies)
Discussion started by: DallasT
0 Replies

9. Shell Programming and Scripting

Perl Script to check file date and size

Hi guys, i am new to perl. I started reading the perl documents and try to come up with some logic. I am trying to create a script that would go into a location, search for todays files, then searches for all .txt files from today. If todays not found, its an error If file size is less... (26 Replies)
Discussion started by: DallasT
26 Replies

10. UNIX for Dummies Questions & Answers

file date check script

I am creating a KSH script and need to check the filedate against the system date. I can get the sys date w. date command, and I was able to get the filedate w. the awk command but when I compare them w. an if condition statement I get syntax error. Not sure what's wrong, and other suggestions on... (4 Replies)
Discussion started by: jaxconsultant
4 Replies

Featured Tech Videos