<?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: Environemnt under cron execution in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/environemnt-under-cron-execution/m-p/2754708#M835402</link>
    <description>The cron environment is intentionally very sparse. You almost certainly do not want to source a .profile in your script. &lt;BR /&gt;&lt;BR /&gt;Your script can explicitly set PATH and export it or a better method is to do something like this:&lt;BR /&gt;&lt;BR /&gt;Let's suppose that this is some kind of Oracle script so the ORACLE_HOME, ORACLE_SID .. needs to be set.&lt;BR /&gt;&lt;BR /&gt;The best way is to create a file. e.g. /usr/local/bin/oraenv.sh that sets and exports these variables and the PATH; this file must not have a return or exit statement.&lt;BR /&gt;Now BOTH the .profile AND your cron script source source /usr/local/bin/oraenv.sh. &lt;BR /&gt;&lt;BR /&gt;The reason you don't source .profile is that several statements (e.g. stty, tabs, ...) require a tty device for stdin &amp;amp; stdout.&lt;BR /&gt;&lt;BR /&gt;You could wrap  those commands in your .profile with&lt;BR /&gt;if [ -t 0 -a -t 1 ]&lt;BR /&gt;  then&lt;BR /&gt;    tset ..&lt;BR /&gt;    stty ..&lt;BR /&gt;    tabs .. &lt;BR /&gt;  fi&lt;BR /&gt;&lt;BR /&gt;but it's much cleaner to have a common file that is references by all the relevant .profiles and scripts.&lt;BR /&gt;&lt;BR /&gt;Regards, Clay&lt;BR /&gt;</description>
    <pubDate>Fri, 28 Jun 2002 17:48:48 GMT</pubDate>
    <dc:creator>A. Clay Stephenson</dc:creator>
    <dc:date>2002-06-28T17:48:48Z</dc:date>
    <item>
      <title>Environemnt under cron execution</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/environemnt-under-cron-execution/m-p/2754705#M835399</link>
      <description>How is the environment determined when a job executes under CRON?  Obviously, the .profile is not being loaded.  When my job executes under CRON, the only thing in the PATH variable is /usr/bin and /usr/sbin.  Should I manually source the .profile for the user in my script?  Or, is there a more elegant solution to setting the environment?</description>
      <pubDate>Fri, 28 Jun 2002 17:42:03 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/environemnt-under-cron-execution/m-p/2754705#M835399</guid>
      <dc:creator>Brian Bientz</dc:creator>
      <dc:date>2002-06-28T17:42:03Z</dc:date>
    </item>
    <item>
      <title>Re: Environemnt under cron execution</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/environemnt-under-cron-execution/m-p/2754706#M835400</link>
      <description>The best bet is to set your environment for your script within the script.  You should always use absolute paths for commands (/usr/bin/ls, etc.) and any other environment variables should be set within the script itself.&lt;BR /&gt;&lt;BR /&gt;You could source the .profile for the user, but since .profile expects an interactive session you will get some errors like "stty: not a typewriter".</description>
      <pubDate>Fri, 28 Jun 2002 17:45:33 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/environemnt-under-cron-execution/m-p/2754706#M835400</guid>
      <dc:creator>Patrick Wallek</dc:creator>
      <dc:date>2002-06-28T17:45:33Z</dc:date>
    </item>
    <item>
      <title>Re: Environemnt under cron execution</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/environemnt-under-cron-execution/m-p/2754707#M835401</link>
      <description>as part of your cron entry:&lt;BR /&gt;&lt;BR /&gt;* * * * * . ./.profile &amp;gt; /dev/null; your_cron_script&lt;BR /&gt;&lt;BR /&gt;HTH&lt;BR /&gt;Marty</description>
      <pubDate>Fri, 28 Jun 2002 17:47:31 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/environemnt-under-cron-execution/m-p/2754707#M835401</guid>
      <dc:creator>Martin Johnson</dc:creator>
      <dc:date>2002-06-28T17:47:31Z</dc:date>
    </item>
    <item>
      <title>Re: Environemnt under cron execution</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/environemnt-under-cron-execution/m-p/2754708#M835402</link>
      <description>The cron environment is intentionally very sparse. You almost certainly do not want to source a .profile in your script. &lt;BR /&gt;&lt;BR /&gt;Your script can explicitly set PATH and export it or a better method is to do something like this:&lt;BR /&gt;&lt;BR /&gt;Let's suppose that this is some kind of Oracle script so the ORACLE_HOME, ORACLE_SID .. needs to be set.&lt;BR /&gt;&lt;BR /&gt;The best way is to create a file. e.g. /usr/local/bin/oraenv.sh that sets and exports these variables and the PATH; this file must not have a return or exit statement.&lt;BR /&gt;Now BOTH the .profile AND your cron script source source /usr/local/bin/oraenv.sh. &lt;BR /&gt;&lt;BR /&gt;The reason you don't source .profile is that several statements (e.g. stty, tabs, ...) require a tty device for stdin &amp;amp; stdout.&lt;BR /&gt;&lt;BR /&gt;You could wrap  those commands in your .profile with&lt;BR /&gt;if [ -t 0 -a -t 1 ]&lt;BR /&gt;  then&lt;BR /&gt;    tset ..&lt;BR /&gt;    stty ..&lt;BR /&gt;    tabs .. &lt;BR /&gt;  fi&lt;BR /&gt;&lt;BR /&gt;but it's much cleaner to have a common file that is references by all the relevant .profiles and scripts.&lt;BR /&gt;&lt;BR /&gt;Regards, Clay&lt;BR /&gt;</description>
      <pubDate>Fri, 28 Jun 2002 17:48:48 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/environemnt-under-cron-execution/m-p/2754708#M835402</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2002-06-28T17:48:48Z</dc:date>
    </item>
    <item>
      <title>Re: Environemnt under cron execution</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/environemnt-under-cron-execution/m-p/2754709#M835403</link>
      <description>Like Clay pointed out, cron and at environments are very sparse for security reasons.  When I write scripts, I sourse files like Clay suggested depending on whether it is an admin user, normal user, superuser.  Once these are setup, it is very clean and can handle all your needs.&lt;BR /&gt;&lt;BR /&gt;Something I really like in Linux is /etc/system/functions.  While some of it would not make sense in other Unices the basic functions for super-user needs are there.&lt;BR /&gt;i.e.&lt;BR /&gt;killproc()&lt;BR /&gt;statproc()&lt;BR /&gt;&lt;BR /&gt;I took the idea back in Redhat 5.0 and ran with it.  I now have some extensive external functions and paths (based on OS) which make scripting a breeze.&lt;BR /&gt;&lt;BR /&gt;Best of Luck!&lt;BR /&gt;Shannon</description>
      <pubDate>Fri, 28 Jun 2002 18:03:00 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/environemnt-under-cron-execution/m-p/2754709#M835403</guid>
      <dc:creator>Shannon Petry</dc:creator>
      <dc:date>2002-06-28T18:03:00Z</dc:date>
    </item>
    <item>
      <title>Re: Environemnt under cron execution</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/environemnt-under-cron-execution/m-p/2754710#M835404</link>
      <description>Adding to the other responses:&lt;BR /&gt;&lt;BR /&gt;This subject matter, i.e. environment variables and non-execution of .profile, is documented in the crontab(1) (i.e. "man crontab") manual page. It is documented in this page, and not in the cron(1M) page, because crontab(1) is a user command (i.e. the user which puts the entry in the crontab) and cron(1M) is a SysAdmin command.</description>
      <pubDate>Mon, 01 Jul 2002 11:32:29 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/environemnt-under-cron-execution/m-p/2754710#M835404</guid>
      <dc:creator>Frank Slootweg</dc:creator>
      <dc:date>2002-07-01T11:32:29Z</dc:date>
    </item>
  </channel>
</rss>

