- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Executing script through 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
тАО10-26-2010 11:42 PM
тАО10-26-2010 11:42 PM
I had faced a similar issue on one server. When i added "/usr/bin/sh
Solved! Go to Solution.
- Tags:
- crontab
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-27-2010 12:01 AM
тАО10-27-2010 12:01 AM
Re: Executing script through cron
Try adding the below line to your script and see if it works..
#!/usr/bin/sh to your script.
Sagar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-27-2010 12:04 AM
тАО10-27-2010 12:04 AM
Re: Executing script through cron
"I had faced a similar issue on one server. When i added "/usr/bin/sh
I have tried this :(
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-27-2010 12:09 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-27-2010 12:16 AM
тАО10-27-2010 12:16 AM
Re: Executing script through cron
Try and give absolute paths to commands not in standard bin directories
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-27-2010 02:21 AM
тАО10-27-2010 02:21 AM
Re: Executing script through cron
If you examine the 'crontask(1)' manpages you will see that the environment that 'cron' provides is very sparse. Specifically the following are set:
HOME=user├в s-home-directory
LOGNAME=user├в s-login-id
PATH=/usr/bin:/usr/sbin:.
SHELL=/usr/bin/sh
This means that environmental variables that you have specified in your login profile don't exist either, by default, since the login profile is not read.
If you profile contains the necessary environmental variables, you can "source" (read) that as the first step of your crontask. A common problem with using the profile, however, is that the standand HP-UX '${HOME}/.profile' contains terminal interactive commands like 'stty' and 'tset'. Since a cron'ed task isn't interactive (associated with a terminal) unless you condition-out this profile code, you get messages of "Not a typewritter" when you cron your task.
A very clean way to handle environmental variables that you want to use in scripts, is to create a separate file of them that you can be "sourced" (read) whenever necessary. By example, you could do:
# cat /home/shrady/env
#!/usr/bin/sh
export PATH=$PATH:/home/shrady/scripts
export SHLIB_PATH=/home/shrady/1981
export TZ=UTC
The interpreter line (the "she-bang") is optional for files that will be sourced. My personal preference is to declare it as a form of documentation at-first-glance.
To use this, do:
. /home/shrady/env
...Note the dot character (".") followed by a space (blank) followed the absolute path of the file you want to read "into" your script. This is what is called "sourcing" a file.
# . /home/shrady/env; /home/shrady/scripts/mything
...or in a crontab:
1 * * * * ./home/shrady/env;/home/shrady/scripts/mything
The file of your variables can also be sourced at the end of your login profile too. Thus, only ONE copy of variables needs to be maintained.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-27-2010 03:17 AM
тАО10-27-2010 03:17 AM
Re: Executing script through cron
It shouldn't be. If you use #! shell, then sh will execute that shell.
>When I added "/usr/bin/sh
You shouldn't have to do that since cron is going to use sh anyway. Unless your script isn't executable?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-27-2010 03:59 AM
тАО10-27-2010 03:59 AM