- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Run cron job
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
тАО02-09-2011 01:48 AM
тАО02-09-2011 01:48 AM
Run cron job
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-09-2011 01:50 AM
тАО02-09-2011 01:50 AM
Re: Run cron job
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-09-2011 05:26 AM
тАО02-09-2011 05:26 AM
Re: Run cron job
I have another question .
Now , if I don't want to run it as a cron job ( because I don't want to change existing cron setting ), I just want to run a looping script on shell - this looping script is to run a command on every 20 seconds .
Can advise what can i do ? thx
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-09-2011 05:56 AM
тАО02-09-2011 05:56 AM
Re: Run cron job
Then you need a loop process with a sleep interval of 20 secs (sleep 20).
Please remember that you should need ensure this process continuity without depend of current work session is closed.
#nohup yourloopscript.sh &
Detailed info about nohup command:
#man nohup
Character "&" executes your script in backgroud mode and "nohup" executes command with hangups and quits ignored.
It's highly recommended that you take note about the Process ID (PID) generated by system when you executes the script in background mode. The PID is the key to kill your script execution on backgroud mode.
Rgds.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-09-2011 06:01 AM
тАО02-09-2011 06:01 AM
Re: Run cron job
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-09-2011 07:12 AM
тАО02-09-2011 07:12 AM
Re: Run cron job
I have tested it , it works .
you recommend to take note the PID , I just try it in a testing server and without write down the PID , I can't find it back ..
can advise if it is really can not find the PID back , it needs to reboot the server if I want to stop the process ? thx
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-09-2011 07:58 AM
тАО02-09-2011 07:58 AM
Re: Run cron job
Please execute this to find your script PID:
#ps -ef|grep
And please send us the command output.
Rgds.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-09-2011 08:33 AM
тАО02-09-2011 08:33 AM
Re: Run cron job
echo $$ > /tmp/
echo $$ shows your current PID, then you redirect this command output to a plain text placed conveniently and with a mnemonic name.
Once catched this number (PID), you have the key to kill the process.
#kill -9 `cat /tmp/
Rgds.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-09-2011 09:05 AM
тАО02-09-2011 09:05 AM
Re: Run cron job
#ps -ef|grep
Look the second field (must be numeric and integer), this is the PID associated at your current script execution, then you should kill this PID:
#kill -9
If you try again, the command output do not show nothing:
#grep -ef|grep
This mean that your script is killed.
After this, improve your script including the syntax explained previously.
Rgds.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-09-2011 10:02 AM
тАО02-09-2011 10:02 AM
Re: Run cron job
This should be trivial to find it if you have a unique name and/or arguments for your script.
UNIX95=EXTENDED_PS ps -C script-name
Note: This is simpler than Jose's ps/grep/grep pipeline.
You could also have your looping script check for the presence or absence of a sentinel file and stop on that.
>Jose: you have the key to kill the process.
#kill -9 `cat /tmp/
Better to eliminate that evil cat:
kill $(< /tmp/
(And only use -9 as last resort.)
- Tags:
- evil cat