Solved

script that terminates after a period

Posted on 2004-08-16
7
142 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
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

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…
The purpose of this article is to demonstrate how we can upgrade Python from version 2.7.6 to Python 2.7.10 on the Linux Mint operating system. I am using an Oracle Virtual Box where I have installed Linux Mint operating system version 17.2. Once yo…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

708 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now