Solved

script that terminates after a period

Posted on 2004-08-16
7
147 Views
Last Modified: 2010-04-22
Hi

I've got a program called scc and I've put this into a script to run daily, how can I write my script that scc will only run until november 2004 and musts never run after that

so in other words I've got my script (script.sh)
***************
inside script.sh:
./scc
***************
and cron runs it daily, I don't want to take out this script after after 3 months (november) I just want to write a script that checks the month and if it matches the 11th month it must not execute scc ?

Any help will be appreciated

Thanks

0
Comment
Question by:bunny47
7 Comments
 
LVL 23

Expert Comment

by:brettmjohnson
ID: 11812170
if [ `date +"%Y%m"` -ge  200411 ] ; then  exit; fi

However, I think it is a bad idea to litter the crontab with such "living-dead" entries.

0
 
LVL 6

Expert Comment

by:de2Zotjes
ID: 11815902
I agree with previous poster. It would be better for your script to do the check on date, and if it sees that november came just sed itself out of the crontab file :-)

if [ `date...` -ge 200411 ]; then
mv "crontab" orig
sed 's/.*"script-name".*//' < orig > "crontab"
killall -1 "crond"
fi
0
 

Author Comment

by:bunny47
ID: 11849747
Thanks for the help, so please help me out, I've got a program scc and it must never run after 3 months down the line and a message must pop up that says "scc does not run anymore"

if [ `date +"%Y%m"` -ge  200411 ] ; then  exit; fi

How can I put this in? Also if it becomes december will it also still not work 200412?

Thanks a mil
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 23

Expert Comment

by:brettmjohnson
ID: 11852474
> How can I put this in?

Just insert these lines into the script.sh before the call to scc
if [ `date +"%Y%m"` -ge  200411 ] ; then  
  logger -s -t $0 "scc should not run anymore.  Please remove the entry from crontab."
  exit;
fi


> Also if it becomes december will it also still not work 200412?

The -ge in the test means 'greater than or equal'  so the script
will still exit in december, and 2005, and forever after (well at
least until the year 21474836)

0
 

Author Comment

by:bunny47
ID: 11858706
Thanks alot, just this one last question to clarify

my scc program (script) looks like this:

mkdir /mnt/scc
mount -t vfat /dev/hda1 /mnt/scc
scc -a -f -j scc.out /

Now if I understand correctly it  must look like this:

if [ `date +"%Y%m"` -ge  200411 ] ; then  
  logger -s -t $0
  exit;
fi
mkdir /mnt/scc
mount -t vfat /dev/hda1 /mnt/scc
scc -a -f -j scc.out /
init 6

Is the above correct will my script and scc not run after the period spesified?

Thanks
0
 
LVL 1

Expert Comment

by:DJSara
ID: 11913920
Yes. The above is correct. Now, your script will  not run after the period specified.
Again, it is recommended that you remove the entry from crontab after it's use is over.
0
 
LVL 23

Accepted Solution

by:
brettmjohnson earned 500 total points
ID: 11914179
My only comment is that
  logger -s -t $0
creates a log entry with no message (only timestamp and program name).

Note that my previous posting logs a message with the text you requested:
  logger -s -t $0 "scc should not run anymore.  Please remove the entry from crontab."

The latter is preferable for anyone perusing the system logs.  The nature of the
problem is mentioned as well a solution.

0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever been frustrated by having to click seven times in order to retrieve a small bit of information from the web, always the same seven clicks, scrolling down and down until you reach your target? When you know the benefits of the command l…
The purpose of this article is to fix the unknown display problem in Linux Mint operating system. After installing the OS if you see Display monitor is not recognized then we can install "MESA" utilities to fix this problem or we can install additio…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question