- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: cron $USER; mysterious shell
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
10-01-2003 07:55 AM
10-01-2003 07:55 AM
Zip $file.zip $file.
While executing shell from command line, everything is fine (I can see file.zip created and attached in email). However if 100% same shell ran thru cron zip file goes nowhere or doesnâ t created at all, cron log file indicate RC=2.
.
What $USER or group cron running under ? I feel that there is some permission problem or maybe there are some other explanation for this phenomenon.
.
Emaildir is my working dir that holds all files including my shell
Thanks. Help !!!!!!!!!
.
drwxrwxr-x 2 root tango 1024 Oct 1 12:44 emaildir
.
-rw-r--r-- 1 tango users 59730 Oct 1 12:44 emaildir_notinpoe.txt
-rw-r--r-- 1 tango users 59730 Oct 1 12:43 emaildir_notinpoe.txt.bkup
-rwxrwxrwx 1 tango users 5650 Oct 1 12:44 emaildir_notinpoe.txt.zip
-rwxrwxrwx 1 tango users 2098 Oct 1 12:44 log
-rw-r--r-- 1 tango users 349 Sep 30 21:00 log.bkup
-rwxrwxr-x 1 root tango 3385 Oct 1 12:41 proc
-rwxrwxr-x 1 root tango 41 Sep 22 10:51 subj
-rwxrwxr-x 1 root tango 3288 Sep 30 11:54 xproc
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-01-2003 07:59 AM
10-01-2003 07:59 AM
Re: cron $USER; mysterious shell
Alternatively use full paths to your files.
Error 2 is ENOENT - No such file or directory. So your file can't be found because you are not in the right directory.
HTH.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-01-2003 08:04 AM
10-01-2003 08:04 AM
Re: cron $USER; mysterious shell
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-01-2003 08:08 AM
10-01-2003 08:08 AM
Re: cron $USER; mysterious shell
Most often it is a lack of full path specifcation. This is seen so often, that the script executes fine outside of cron. If you are executing a script, insure full paths are defined for your script contents, i.e. file locations, commands, etc.
Best of luck.
Regards,
dl
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-01-2003 08:09 AM
10-01-2003 08:09 AM
Re: cron $USER; mysterious shell
When things work correctly from the command line but not from cron the problem is almost always an environment problem. cron by design has a very sparse environment. Your .profile does NOT get sourced by cron so no environment variables that may be set up through it will be there. Your best bet is to create an environment script that you source from the script your run from cron. In your environment script you should set your PATH, SHLIB_PATH, and any other variables you may need.
In addition I highly recommend using the FULL path to any commands you use. That way you are absolutely sure about exactly what is running.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-01-2003 08:10 AM
10-01-2003 08:10 AM
Re: cron $USER; mysterious shell
HTH.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-01-2003 08:26 AM
10-01-2003 08:26 AM
Re: cron $USER; mysterious shell
and now I'm using a complete path to files even making cd $WDIR
.
Just made very clear test: cp similar shell that works fine and produces .zip file into
my WDIR, changed WDIR variable, changed cron to point to WDIR/proc ,tried to run and got same bad results: zip and gzip files cannot be created, cron log file has rc=2.
.
Don't have any idea. Will keep you posted.
Thanks to all.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-01-2003 08:39 AM
10-01-2003 08:39 AM
Solution#!/usr/bin/sh
(or #!/usr/bin/ksh or #!/opt/perl/bin/perlm whatever) The reason is that you don't want an arbitrary shell to run your script. You want the correct one (remember, cron does not login). Now to trace the results, add this as the second line after the interpreter line:
set -x
(this assumes your shell is the POSIX shell, or ksh or even bash, but not csh where everything is different). Now run yur script and direct the results into a file:
/path_to_script/myscript 1>/var/tmp/trace1 2>&1
then change cron's entry to the same as above (after the time schedule values) except change trace1 to trace2. Then compare the results.
BTW: I notice 777 permissions on emaildir_notinpoe.txt.zip and log. Usually this means that someone is trying to solve permission issues with a shotgun. I doubt that emaildir_notinpoe.txt.zip or log are runnable programs so execute should not be set at all, and sine writability fir the world is set, anyone logged in can trash your files. Be very cautious with 666 and 777 permissions--they are very seldom correct or what is desired.
Bill Hassell, sysadmin