- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: How to tell whether a script is run by cron or...
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
Forums
Discussions
Discussions
Discussions
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
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
08-24-2001 09:46 AM
08-24-2001 09:46 AM
if it is run manually the script should send e-mail to database support group and if it is run by cronjob it should send PAGER notification to database support group.
How do it check whether the is run by cron or manually. Is there any process type that I can check?
Any help is greatly appreciated.
Thanks
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2001 09:54 AM
08-24-2001 09:54 AM
Re: How to tell whether a script is run by cron or manually
Good luck
Chris
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2001 10:00 AM
08-24-2001 10:00 AM
Solutioncrontab jobs do not have attached tty ( that's why any standard output or standard error are sent to the mail ).
Any interactive process got an attached tty.
if you issue the command :
#ps -ef ? more
You will find the TTY under in the six column.
So, integrate in your script the following test :
WHICH_PS=`ps -ef ? grep
if [[ "$WHICH_PS" = "?" ]]
then
... it's a cron job execution ...
else
... it's a manual execution
fi
Good luck.
Magdi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2001 10:03 AM
08-24-2001 10:03 AM
Re: How to tell whether a script is run by cron or manually
Magdi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2001 10:07 AM
08-24-2001 10:07 AM
Re: How to tell whether a script is run by cron or manually
I think I should re-phrase my questions. I want to write a script that I have a capability to check itself whether it was run by cron or manually. If it was run by cront than I will perform certain task and if it was run manually it should do something else.
My goal it is to have a script that have dual usage manual or cron.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2001 10:11 AM
08-24-2001 10:11 AM
Re: How to tell whether a script is run by cron or manually
This is what I am looking for.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2001 10:16 AM
08-24-2001 10:16 AM
Re: How to tell whether a script is run by cron or manually
VAR=`tty`
if [ "$VAR" = "not a tty" ]
then
echo Not running from a tty session
else
echo Running from tty $VAR
fi
Darrell
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2001 10:21 AM
08-24-2001 10:21 AM
Re: How to tell whether a script is run by cron or manually
if you integrate this solution and you plan to run the script manually, you do not need to run it with no hang up like :
#nohup myScript.sh
Because no hang up will not generate an attached tty for the myScript.sh process !
( I'm sure that you will not do it : " nohup ", but in order that the reply be complete ).
Nice time.
Magdi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2001 11:38 AM
08-24-2001 11:38 AM
Re: How to tell whether a script is run by cron or manually
Thanks for your help.