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
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
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-11-2011 06:36 AM
10-11-2011 06:36 AM
Cron job
Hello,
I am trying to run a simple script via cron on HP-UX 11i. Script executed manually works fine, but when executed via cron, nothing happens. Script seems to run, but no result.
1.) name of the script is "xxxx.sh"
2.) script is setup with 777 permission
3.) script location is /home/user
4.) script runs as "root" user
5.) script group owner is "sys"
6.) script in cron looks like this: 00,15,30,45 * * * * /home/user/xxxx.sh
In a cron, do I need to execute script same as I do it manually ( sh /home/user/xxxx.sh ), or do I just specify a path for script?
Miro
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-11-2011 07:25 AM
10-11-2011 07:25 AM
Re: Cron job
Have you checked the /var/adm/cron/log file to see what it shows?
When a script does not run via cron it is usually because there is some environment variable that is not set. You must remember that cron has a very sparse environment. It will NOT have the same environment you have when you log in.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-11-2011 07:36 AM
10-11-2011 07:36 AM
Re: Cron job
Hi:
As Patrick noted, a 'crontask' is given only a rudimentary set of environment variables. The 'crontab' manpages document this. You automatically get:
HOME=user’s-home-directory
LOGNAME=user’s-login-id
PATH=/usr/bin:/usr/sbin:.
SHELL=/usr/bin/sh
...with everything else you normally have defined in a login profile absent.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-11-2011 08:00 AM
10-11-2011 08:00 AM
Re: Cron job
Here is output from /var/adm/cron/log
CMD: /home/mvr/xxxx.sh
> root 4813 c Wed Sep 28 23:30:00 EDT 2011
< root 4813 c Wed Sep 28 23:30:00 EDT 2011 rc=127
< root 4810 c Wed Sep 28 23:30:01 EDT 2011
< root 4811 c Wed Sep 28 23:30:01 EDT 2011
Do I need to specify enviroment for "root" user?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-11-2011 09:32 AM
10-11-2011 09:32 AM
Re: Cron job
So just use full pathes and only variables, which you define inside the script.
HTH
V.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-11-2011 10:56 AM
10-11-2011 10:56 AM
Re: Cron job
@mvr wrote:
Here is output from /var/adm/cron/log
CMD: /home/mvr/xxxx.sh
> root 4813 c Wed Sep 28 23:30:00 EDT 2011
< root 4813 c Wed Sep 28 23:30:00 EDT 2011 rc=127
< root 4810 c Wed Sep 28 23:30:01 EDT 2011
< root 4811 c Wed Sep 28 23:30:01 EDT 2011
Do I need to specify enviroment for "root" user?
First, a return code of 127 points to a non-existent file.
I'd add '-x' to the interpreter line of your script:
#!/usr/bin/sh -x
...and let 'cron' mail you the output (trace).
By the way, setting permissions on a script to 777 is a bad choice -- anyone could change the script! A better choice would be 755 if everyone needs to be able to execute it. Shell scripts need only be readable and executable to be run.
Regards!
...JRF...