- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Issue on Cron
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-08-2011 06:41 AM
тАО04-08-2011 06:41 AM
Issue on Cron
I need a script to be executed every second. So, I have scheduled that in cron. But I found its not getting executed.
This is my crontab entry.
* * * * * sh /home/glance/Check_Perform_Action.sh
The content of Check_Perform_Action.sh
is below.
if [ -e /home/glance/Perform_Action.sh ]
then
./Perform_Action.sh
sleep 10
rm -rf Perform_Action.sh
fi
When the Perform_Action.sh executed, a file has to be generated. Thats the content of that file.
Kindly help.
Thanks in Advance!!!
- Tags:
- crontab
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-08-2011 06:48 AM
тАО04-08-2011 06:48 AM
Re: Issue on Cron
second thing: if some other script/program is not generating the Perform_Action.sh script, and you are deleting it on the line just before the last, how do you expect it to run again, 10 seconds later ?
UNIX because I majored in cryptology...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-08-2011 06:53 AM
тАО04-08-2011 06:53 AM
Re: Issue on Cron
I need to run the Perform_Action.sh Script when it is found in the specified path.
So, I need a script to check whether the Perform_Action.sh script is present or not. If it exist, then it should run the Perform_Action.sh.
Thanks!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-08-2011 07:08 AM
тАО04-08-2011 07:08 AM
Re: Issue on Cron
you cron script check_perform_action, runs every minute,
if the script perform_action exists
runs it, waits for 10 seconds after run is complete and then deletes it
then exits
if the script perform_action does not exist at the time check_perform_action, you are out of luck. check_perform_action exits without doing anything
I think you want something like that as your check_perform_action.sh script
s=1
while [ $s -le 58 ]
do
if [ -e /home/glance/Perform_Action.sh ]
then
./Perform_Action.sh
sleep 10
rm -rf Perform_Action.sh
exit 0
fi
(( s=$s+1 ))
sleep 1
done
This is not a bullet proof script but it runs in a way close to how you want it to run
UNIX because I majored in cryptology...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-08-2011 07:19 AM
тАО04-08-2011 07:19 AM
Re: Issue on Cron
Rick
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-08-2011 07:25 AM
тАО04-08-2011 07:25 AM
Re: Issue on Cron
When I run the Check_Perform_Action.sh manually, I am not facing any issue. The Perform_Action.sh is executed properly and I am getting the desired output. Only when I schedule it through cron, I am facing issue.
This is my Perform_Action.sh:
i=`hostname`
bdf >> /home/glance/Action_Performed_$i
Thanks!!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-08-2011 07:30 AM
тАО04-08-2011 07:30 AM
Re: Issue on Cron
I explained how your script works.
you have a wrong assumption:
your Check script thru cron will only run once every minute and if yout action script is there it will run it once and exit. If it is not there, it will exit without doing anything.
under the circumstances, what issue are you talking about ? you want something from this script but you are not telling it how to do it. Do you know the famous saying "Computers do what you TELL them to do, NOT what you WANT them to do" ? It is famous for a reason.
I gave you a rough example how to accomplish it above or you can do as Rick says and leave the cron stuff aside and leave the script running all the time with 1 second sleep intervals.
UNIX because I majored in cryptology...