<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: cron $USER;  mysterious shell in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/cron-user-mysterious-shell/m-p/3083186#M143139</link>
    <description>Yes, I do  cd $WDIR all the time.</description>
    <pubDate>Wed, 01 Oct 2003 15:04:51 GMT</pubDate>
    <dc:creator>Vlad_11</dc:creator>
    <dc:date>2003-10-01T15:04:51Z</dc:date>
    <item>
      <title>cron $USER;  mysterious shell</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/cron-user-mysterious-shell/m-p/3083184#M143137</link>
      <description>My shell does:&lt;BR /&gt;Zip $file.zip  $file.&lt;BR /&gt;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.&lt;BR /&gt;.&lt;BR /&gt;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.&lt;BR /&gt;.&lt;BR /&gt;Emaildir  is my working dir that holds all files including my shell &lt;PROC&gt; as shown below.&lt;BR /&gt;&lt;BR /&gt;Thanks. Help !!!!!!!!!&lt;BR /&gt;&lt;BR /&gt;.&lt;BR /&gt; drwxrwxr-x   2 root       tango       1024 Oct  1 12:44 emaildir&lt;BR /&gt;&lt;BR /&gt;.&lt;BR /&gt;-rw-r--r--         1 tango       users        59730 Oct  1 12:44 emaildir_notinpoe.txt&lt;BR /&gt;-rw-r--r--         1 tango      users        59730 Oct  1 12:43 emaildir_notinpoe.txt.bkup&lt;BR /&gt;-rwxrwxrwx    1 tango     users         5650 Oct  1 12:44 emaildir_notinpoe.txt.zip&lt;BR /&gt;-rwxrwxrwx    1 tango     users         2098 Oct  1 12:44 log&lt;BR /&gt;-rw-r--r--        1 tango      users          349 Sep 30 21:00 log.bkup&lt;BR /&gt;-rwxrwxr-x     1 root         tango         3385 Oct  1 12:41 proc&lt;BR /&gt;-rwxrwxr-x     1 root         tango         41 Sep 22 10:51 subj&lt;BR /&gt;-rwxrwxr-x     1 root         tango        3288 Sep 30 11:54 xproc&lt;BR /&gt;&lt;/PROC&gt;</description>
      <pubDate>Wed, 01 Oct 2003 14:55:22 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/cron-user-mysterious-shell/m-p/3083184#M143137</guid>
      <dc:creator>Vlad_11</dc:creator>
      <dc:date>2003-10-01T14:55:22Z</dc:date>
    </item>
    <item>
      <title>Re: cron $USER;  mysterious shell</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/cron-user-mysterious-shell/m-p/3083185#M143138</link>
      <description>Make sure your script cd's to your working directory. Cron will default to your home directory when it runs the script.&lt;BR /&gt; &lt;BR /&gt;Alternatively use full paths to your files.&lt;BR /&gt; &lt;BR /&gt;Error 2 is ENOENT - No such file or directory. So your file can't be found because you are not in the right directory.&lt;BR /&gt;&lt;BR /&gt;HTH.</description>
      <pubDate>Wed, 01 Oct 2003 14:59:20 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/cron-user-mysterious-shell/m-p/3083185#M143138</guid>
      <dc:creator>Brian Bergstrand</dc:creator>
      <dc:date>2003-10-01T14:59:20Z</dc:date>
    </item>
    <item>
      <title>Re: cron $USER;  mysterious shell</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/cron-user-mysterious-shell/m-p/3083186#M143139</link>
      <description>Yes, I do  cd $WDIR all the time.</description>
      <pubDate>Wed, 01 Oct 2003 15:04:51 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/cron-user-mysterious-shell/m-p/3083186#M143139</guid>
      <dc:creator>Vlad_11</dc:creator>
      <dc:date>2003-10-01T15:04:51Z</dc:date>
    </item>
    <item>
      <title>Re: cron $USER;  mysterious shell</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/cron-user-mysterious-shell/m-p/3083187#M143140</link>
      <description>Vlad -&lt;BR /&gt;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.&lt;BR /&gt;&lt;BR /&gt;Best of luck.&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;dl</description>
      <pubDate>Wed, 01 Oct 2003 15:08:27 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/cron-user-mysterious-shell/m-p/3083187#M143140</guid>
      <dc:creator>Dave La Mar</dc:creator>
      <dc:date>2003-10-01T15:08:27Z</dc:date>
    </item>
    <item>
      <title>Re: cron $USER;  mysterious shell</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/cron-user-mysterious-shell/m-p/3083188#M143141</link>
      <description>The user cron runs under depends on the user whose crontab contains the job.  If you use root's crontab, then all jobs will run as the root user.&lt;BR /&gt; &lt;BR /&gt;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.&lt;BR /&gt; &lt;BR /&gt;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.</description>
      <pubDate>Wed, 01 Oct 2003 15:09:14 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/cron-user-mysterious-shell/m-p/3083188#M143141</guid>
      <dc:creator>Patrick Wallek</dc:creator>
      <dc:date>2003-10-01T15:09:14Z</dc:date>
    </item>
    <item>
      <title>Re: cron $USER;  mysterious shell</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/cron-user-mysterious-shell/m-p/3083189#M143142</link>
      <description>Do you set WDIR in your script? If not, then it is not defined in your cron environment and the cd will fail. For best results, explcitly cd to your path or use full paths.&lt;BR /&gt;&lt;BR /&gt;HTH.</description>
      <pubDate>Wed, 01 Oct 2003 15:10:22 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/cron-user-mysterious-shell/m-p/3083189#M143142</guid>
      <dc:creator>Brian Bergstrand</dc:creator>
      <dc:date>2003-10-01T15:10:22Z</dc:date>
    </item>
    <item>
      <title>Re: cron $USER;  mysterious shell</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/cron-user-mysterious-shell/m-p/3083190#M143143</link>
      <description>Yes, defenetely I have defined WDIR=/xxx/xxx/&lt;BR /&gt;and now I'm using a complete path to files even making cd $WDIR&lt;BR /&gt;.&lt;BR /&gt;Just made very clear test: cp similar shell that works fine and produces .zip file into&lt;BR /&gt;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.&lt;BR /&gt;.&lt;BR /&gt;Don't have any idea. Will keep you posted.&lt;BR /&gt;&lt;BR /&gt;Thanks to all.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 01 Oct 2003 15:26:11 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/cron-user-mysterious-shell/m-p/3083190#M143143</guid>
      <dc:creator>Vlad_11</dc:creator>
      <dc:date>2003-10-01T15:26:11Z</dc:date>
    </item>
    <item>
      <title>Re: cron $USER;  mysterious shell</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/cron-user-mysterious-shell/m-p/3083191#M143144</link>
      <description>VERY IMPORTANT: cron does NOT login. Therefore, NOTHING from your normal login environment is setup from /etc/profile and .profile so you do not the normal PATH or virtually anything else. The very easiest way to check a cron job that runs fine from an interactive shell is to trace the script. But first: EVERY shell script must start with the required interpreter, like this:&lt;BR /&gt; &lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt; &lt;BR /&gt;(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:&lt;BR /&gt; &lt;BR /&gt;set -x&lt;BR /&gt; &lt;BR /&gt;(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:&lt;BR /&gt; &lt;BR /&gt;/path_to_script/myscript 1&amp;gt;/var/tmp/trace1 2&amp;gt;&amp;amp;1&lt;BR /&gt; &lt;BR /&gt;then change cron's entry to the same as above (after the time schedule values) except change trace1 to trace2. Then compare the results.&lt;BR /&gt; &lt;BR /&gt;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.</description>
      <pubDate>Wed, 01 Oct 2003 15:39:51 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/cron-user-mysterious-shell/m-p/3083191#M143144</guid>
      <dc:creator>Bill Hassell</dc:creator>
      <dc:date>2003-10-01T15:39:51Z</dc:date>
    </item>
  </channel>
</rss>

