Solved

script that terminates after a period

Posted on 2004-08-16
7
149 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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

Command Line Tips and Tricks

The command line is a powerful tool at the disposal of every Linux user. Although Linux distros come with beautiful user interfaces, it's worthwhile to learn the command line because it allows you to do a number of things that you otherwise cannot do from the GUI.  

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…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

635 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