Cron Cycle Save setsite Error

Homepage Clovertech Forums Read Only Archives Cloverleaf Cloverleaf Cron Cycle Save setsite Error

  • Creator
    Topic
  • #51214
    Darren Tomlinson
    Participant

    We are attempting to set up a cron job to automatically cycles the SMAT files.

Viewing 22 reply threads
  • Author
    Replies
    • #69204
      Russ Ross
      Participant

      My first thought is to make sure you are seting the environment up before having cron run any commands.

      When you login interactively the envirnment is setup via the .profile login process but not for cron jobs.

      There are likely many posts showing how to use cron to cycle SMAT files you can also reference and here is one that shows how I do it:

      <a href="http://clovertech.infor.com/viewtopic.php?t=1921&&#8221; class=”bbcode_url”>http://clovertech.infor.com/viewtopic.php?t=1921&amp;

      Here is my .profile.cron file I run to setup my hci environmnt in cron before doing any commands or scripts:

      Code:

      # Begin Module Header =========================================================
      #
      # This file is intended to be sourced from within an hci cron entry
      # for the prupose of setting up the environment correctly
      #
      # The cron environment is not the same as the hci environment
      # because the $HOME/.profile does not get run for cron jobs
      #
      #========
      # Inputs:
      #========
      #
         hci_root=$1
         hci_site=$2
      #
      #==============
      # Normal Usage:
      #==============
      #
      #   Example of how to use this from cron to run batch_003 very night at 9:00 PM Monday thru Friday
      #
      #   00 21 * * 1-5 /bin/ksh -c ‘eval . ~/.profile.cron /quovadx/qdx5.2/integrator prod_batch; $HCISITEDIR/scripts/_003/iftp_003_cron_entry.ksh’
      #
      #   Example of how to echo the environemnt variables to files /hcitest/env.cron and /hcitest/path.cron at 11:47 AM
      #
      #   47 11 * * * /bin/ksh -c ‘eval . ~/.profile.cron /quovadx/qdx5.2/integrator prod_batch; env|sort >/hcitest/env.cron; parse_path >/hcitest/path.cron’
      #
      #
      #=========
      # History:
      #=========
      #
      # 2002.05.08 Russ Ross
      #          – wrote initial version.
      #
      # 2005.04.12 Russ Ross
      #          – modified for the QDX 5.2.2 upgrade.
      #
      # 2008.09.09 Russ Ross
      #          – modified for the QDX 5.6 rev2 upgrade.
      #
      # End Module Header ============================================================

      #———————
      # define the functions
      #———————

         . /quovadx/qdx5.6/integrator/mda_global/scripts/do_function.ksh

      #————————————
      # define the default HCI profile PATH
      #————————————

         set_HCI_PROFILE_PATH

      #———————————————
      # Make sure our root and site are set
      #———————————————

         setroot -clear
         setroot $hci_root $hci_site

      #———————————————
      # define other necessary environment variables
      #———————————————

         set_IGNORE_VMFULL
         set_MDA_ARCHIVE_ROOT
         set_MDA_BATCH_ENV
         set_MDA_HCIROOT_OFF_LIST
         set_MDA_UPDIR

      Here is the do_functions.ksh script that gets called:

      Code:

      #!/usr/bin/ksh

      function set_IGNORE_VMFULL {
         export IGNORE_VMFULL=1
      }

      function set_HCI_PROFILE_PATH {
         PATH=/usr/bin:/etc:/usr/sbin:/usr/ucb:$HOME/bin:/usr/bin/X11:/sbin:.:/usr/local/bin:/usr/local/scripts
         export PATH
      }

      function set_MDA_ARCHIVE_ROOT {
         export MDA_ARCHIVE_ROOT=”/oldmsgs/5.6″
      }

      function set_MDA_BATCH_ENV {
         MDA_BATCH_ENV=”`echo $HCISITE | cut -b 1-10`”
         if [[ “$MDA_BATCH_ENV” != “test_batch” && “$MDA_BATCH_ENV” != “prod_batch” ]]; then
             MDA_BATCH_ENV=”bogus_batch”
         fi
         export MDA_BATCH_ENV=$MDA_BATCH_ENV
      }

      function set_MDA_HCIROOT_OFF_LIST {
         if [[ `hostname` = “mdahub4” || `hostname` = “mdahub8sna” || `hostname` = “mdahub8” || `hostname` = “mdahub9″ ]]; then
             export MDA_HCIROOT_OFF_LIST=”qdx5.2″
         fi
      }

      function set_MDA_UPDIR {
         export MDA_UPDIR=”/upgrade”
      }

      function gohome {
         cd `grep “^$1:” /etc/passwd | awk -F: ‘{print $6}’`
      }

      function goprocs {
         cd $HCISITEDIR/exec/processes/$1
      }

      function goscripts {
         cd $HCISITEDIR/scripts/$1
      }

      function psgrep {
         echo “”
         ps -ef | head -1
         ps -ef | grep $1 | grep -v grep
         echo “”
      }

      function set522 {
         setroot -clear
         setroot /quovadx/qdx5.2/integrator $1
         showroot
      }

      function set56 {
         export ROOT=”/quovadx/qdx5.6/integrator”
         export SITE=$1
         currentDir=`pwd`
         cd $HOME
         . ~/.profile
         cd $currentDir
      }

      Russ Ross
      RussRoss318@gmail.com

    • #69205
      Darren Tomlinson
      Participant

      my DBA is trying to write his own cron and getting issues.  he says:

      I made an entry in crontab that says:

      /home/hci/.profile; /scripts/test.sh

      When cron evaluates the .profile to setup what I hoped would be the hci user

    • #69206
      Robert Kersemakers
      Participant

      Hi Darren,

      I have no access to our cron scripts/settings (damn those administrators…) but if I remember correctly we use a ‘su – hci’ to switch to user hci and then execute the command/script. This way all environment settings/variables are set.

      I googled it just now; is it ‘su – hci -c ‘? Your DBA will know.

      Zuyderland Medisch Centrum; Heerlen/Sittard; The Netherlands

    • #69207
      Troy Morton
      Participant

      We set all our crons up under the hci user to eliminate the issues of getting the environemnt set up and having the correct privlidges to $HCIROOT and $HCISITEDIR.

    • #69208

      If you can’t set up the hci environment in the profile, you will need to set it up in the beginning of the script. Do a search for “cron” on the forum, there are a few real good discussions on the subject. That is how I learned how to do it. Also, like Troy said, we set all of our cron jobs up as hci. Log into the box as hci and then do crontab -e.

      -- Max Drown (Infor)

    • #69209
      Darren Tomlinson
      Participant

      if i sign in as hci and run a setsite or any other cloverleaf specific command, everything is fine.

      i tried running a very simple script by hand (while still being signed in as hci in the same terminal as above):

      setsite test1

      cd $HCISITEDIR

      pwd

      the setsite line errors out saying:

      “/message_logs/new.sh: line 1: setsite: command not found”

      if i do a which on setsite, i get this:

      -bash-3.2$ which setsite

      /usr/bin/which: no setsite in (/quovadx/qdx5.6/integrator/test/bin:/quovadx/qdx5.6/integrator/test2/scripts:/quovadx/qdx5.6/integrator/bin:/quovadx/qdx5.6/integrator/contrib:/quovadx/qdx5.6/integrator/sbin:/quovadx/qdx5.6/integrator/dbms/bin:/quovadx/qdx5.6/integrator/tcl/bin:/quovadx/qdx5.6/integrator/clgui/bin:/quovadx/qdx5.6/integrator/clgui/java/bin:/quovadx/qdx5.6/integrator/usercmds:/usr/bin:/etc:/usr/sbin:/usr/ucb:/home/hci/bin:/usr/bin/X11:/sbin:.:/usr/local/bin:/usr/local/scripts:/bin)

      why can a simple script not find setsite and why can a which command also not find it?

    • #69210
      Russ Ross
      Participant

      Both methods of scripting or typing at the command line will find and execute setstie if the environment is suffeciently set.

      Since setsite is a function and not a script it can seem hidden when using the which command to try and find it.

      The which command will not find setsite because it is a function in the $FPATH which sadly the which command will not look at.

      If I echo my $FPATH I get

      /quovadx/qdx5.6/integrator/kshlib

      which is were my setsite function is located.

      Russ Ross
      RussRoss318@gmail.com

    • #69211
      Darren Tomlinson
      Participant

      russ, by your assumption that if the environment is set correctly, seems to say that ours is not, since setsite is not found by the script.  so how could it be wrong, and how do i figure it out and correct it?

    • #69212
      Gary Atkinson
      Participant

      Not sure if this was already posted, but I use the script “hcisetenv”, which is found in the $HCIROOT/sbin directory.

    • #69213
      Russ Ross
      Participant

      I can only assist you with how to go about identifying if a deficient environment is your problem.

      It will still be up to you to do the analysis and remediation but this should help with that.

      When I had the same challenge in the beginning, I went about identifying my environment defeciencies which was my first step to resolving them.

      While at the command prompt where things worked, I did something like the following to establish what a suffecient environment looks like:

      Code:


      cd /work; # or somewhere to hold the information files to be created
      env|sort >good.env
      echo $PATH:$FPATH | tr : ’12’ >good.path
      functions >good.functions

      Then in cron or a script that was having environment related problems like we are talking about, I do something like:

      Code:


      cd /work; # or somewhere to hold the information files to be created
      env|sort >script.env
      echo $PATH:$FPATH | tr : ’12’ >script.path
      functions >script.functions

      Once the informational files are created then a side by side analysis will hopefully point out the deficiencies.

      We have cron entires that generate these sort of informational files daily in to help with identifying environment issues when needed.

      Fortunately, we got all the environment issues taken care of nad haven’te had need of these files for many years but they were handy in the beginning.

      Here are some of my cron entries to give you a tangible example of the concept:

      Code:

      #
      #   ****************************************************************************
      #   document the cron environment **********************************************
      #   ****************************************************************************
      #
      #      ———————-
      #      every day near 5:00 AM
      #      ———————-
      #
      02 05 * * * /bin/ksh -c ‘eval . ~/.profile.cron /quovadx/qdx5.6/integrator prod_doc_mgt    ; env|sort >$HCISITEDIR/cron.env; parse_path >$HCISITEDIR/cron.path; functions >$HCISITEDIR/cron.functions’
      07 05 * * * /bin/ksh -c ‘eval . ~/.profile.cron /quovadx/qdx5.6/integrator prod_hdx        ; env|sort >$HCISITEDIR/cron.env; parse_path >$HCISITEDIR/cron.path; functions >$HCISITEDIR/cron.functions’
      12 05 * * * /bin/ksh -c ‘eval . ~/.profile.cron /quovadx/qdx5.6/integrator prod_ris        ; env|sort >$HCISITEDIR/cron.env; parse_path >$HCISITEDIR/cron.path; functions >$HCISITEDIR/cron.functions’

      Russ Ross
      RussRoss318@gmail.com

    • #69214

      When you run a script from cron, the hci environment is not set. Logging in from the command line is called “inerative mode” and the environment is setup using the various files such as ~/.profile. This includes the PATH and the environmental variable like HCIROOT and HCISITEDIR. Cron does not run in an interactive mode, so you have to set up the environment in the cron script before using cloverleaf commands such as setsite.

      Here is an example of how I do it.

      ~/.profile.cron

      Code:

      export HOST=bhciigp
      export CL_INSTALL_DIR=/hci/quovadx/qdx5.6
      export HOSTNAME=bhciigp.boone.org

      eval `${CL_INSTALL_DIR}/integrator/sbin/hcisetenv -root ksh $*`

      Cron Entry:

      Code:

      05,35 * * * * . ~/.profile.cron; /hci/bin/monitor/edb_check.tcl sitebn

      Beginning of the script:

      Code:

      #!/hci/quovadx/qdx5.6/integrator/bin/tcl

      global HciRoot
      set hciSite [lindex $argv 0]

      # Set up the environment for Cloverleaf commands
      eval [exec $HciRoot/sbin/hcisetenv -root tcl $HciRoot $hciSite]

      -- Max Drown (Infor)

    • #69215
      Steve Carter
      Participant

      Have you tried:

      * * * * * (setroot ; whatEver.script) >/dev/null 2>&1

      This assumes that you’re utilizing hci’s cron.  This works fine for me.

      Steve

    • #69216

      Steve Carter wrote:

      Have you tried:

      * * * * * (setroot ; whatEver.script) >/dev/null 2>&1

      This assumes that you’re utilizing hci’s cron.  This works fine for me.

      Steve

      When I try that in cron in my environment, this is what I get:

      Code:

      /bin/sh: setroot: command not found

      -- Max Drown (Infor)

    • #69217
      Steve Carter
      Participant

      You probably need to add the ‘setroot’ function to hci’s profile:

      function setroot

      {

         eval `${QUOVADX_INSTALL_DIR}/integrator/sbin/hcisetenv -root ksh $*`

      }

      Steve

    • #69218

      By profile, do you mean the ~/.profile file?

      -- Max Drown (Infor)

    • #69219
      Steve Carter
      Participant

      Yes.

    • #69220

      I do not believe the .profile file is loaded when a cron script is fired off. Are you sourcing it in your cron jobs?

      -- Max Drown (Infor)

    • #69221
      Chris Williams
      Participant

      When you log in as hci your environment is set automatically for you as part of the login process. From the system prompt, you should type in

      Code:

      set | more

      which will allow you to page through ALL of your existing environment variables that apply to user hci.

      cron does not go through the same steps to set things up so you must explicitly set the environment variables you need for your cron jobs. If you are using the crontab file for user hci, you can place all these environment settings at the beginning of the crontab file above the job entries, and they will apply to all your cron jobs.

    • #69222

      Chris Williams wrote:

      When you log in as hci your environment is set automatically for you as part of the login process. From the system prompt, you should type in

      Code:

      set | more

      which will allow you to page through ALL of your existing environment variables that apply to user hci.

      cron does not go through the same steps to set things up so you must explicitly set the environment variables you need for your cron jobs. If you are using the crontab file for user hci, you can place all these environment settings at the beginning of the crontab file above the job entries, and they will apply to all your cron jobs.

      That’s what I’ve been saying. 🙂

      -- Max Drown (Infor)

    • #69223
      Chris Williams
      Participant

      Yes, exactly, Max.

      Users should be aware that it is not only the ~/.profile file. It’s also /etc/profile, and ~/.profile.local.start, and ~/.profile.local.end, and whatever else gets called from the profile files.

      Seeing what set returns gives you the end result of all of that. And if the list looks intimidating, just cut and paste the results into crontab.

      Cheers.

    • #69224
      Mark Thompson
      Participant

      We’re running AIX 5.3 with crontab entries like this:

      30 7 * * 1-5 setroot; setsite s7_prod; queue_depth_report

      - Mark Thompson
      HealthPartners

    • #69225
      Kevan Riley
      Participant

      Here’s what we do…  First a sample line from Cron:

      0 0 * * * /home/hci/scripts/run_cyclesave_new /quovadx/qdx5.6/integrator ctz_cer_prd 35 > /home/hci/cycle_save_logs/cyclemsg_ctz_cer_prd.log 2>&1

      where /home/hci/scripts/run_cyclesave_new is:

      Quote:


      #!/bin/ksh

      FPATH=${1}/kshlib

      export QUOVADX_INSTALL_DIR=`echo $1 | cut -d / -f1-3`

      eval `${QUOVADX_INSTALL_DIR}/integrator/sbin/hcisetenv -root ksh $1 $2`

      #setroot $1 $2

      tcl /home/hci/scripts/cyclesaveall.tcl $3

      Args $1 is the “root” (/quovadx/qdx5.6/integrator) $2 is the site (ctz_cer_prd), and $3 is the number of days of SMAT to keep (35 days).  Then our cycle save script is then in Tcl.  I’d rather not paste that as it was originally written/provided by Healthvision.

      Kevan Riley

      Adventist Health System – Information Services

      Lake Mary, FL

    • #69226
      Darren Tomlinson
      Participant

      Russ, you were correct that the environment is set up completely different when run from command line versus in a script.  here is the obvious difference.  now, we just need to figure out how to correct this.

      From Script:

      HOME=/home/hci

      LOGNAME=hci

      OLDPWD=/home/hci

      PATH=/usr/bin:/bin

      PWD=/env_test

      SHELL=/bin/sh

      SHLVL=2

      USER=hci

      _=/usr/bin/env

      From Command Line:

      BLT_LIBRARY=/quovadx/qdx5.6/integrator/tcl/lib/blt2.4

      CATPATH=/quovadx/qdx5.6/integrator/hcitest/exec/databases/catalog

      CLASSPATH=/quovadx/qdx5.6/integrator/hcitest/java_uccs:.:/quovadx/qdx5.6/integrator/clgui/lib/cljava.jar:/quovadx/qdx5.6/integrator/java_uccs:

      CL_INSTALL_DIR=/quovadx/qdx5.6

      CVS_RSH=ssh

      DBDPATH=/quovadx/qdx5.6/integrator/hcitest/exec/databases

      DBFPATH=/quovadx/qdx5.6/integrator/hcitest/exec/databases

      DBTAF=/quovadx/qdx5.6/integrator/hcitest/exec/databases/rdm.taf

      DBTMP=/quovadx/qdx5.6/integrator/hcitest/exec/databases

      DEV_NULL=/dev/null

      FPATH=/quovadx/qdx5.6/integrator/kshlib

      G_BROKEN_FILENAMES=1

      HCILICFILE=/quovadx/qdx5.6/integrator/vers/license.dat

      HCIROOT=/quovadx/qdx5.6/integrator

      HCISITEDIR=/quovadx/qdx5.6/integrator/hcitest

      HCISITE=hcitest

      HCIVERSION=5.6

      HISTSIZE=1000

      HOME=/home/hci

      HOSTNAME=PIM

      INPUTRC=/etc/inputrc

      KDEDIR=/usr

      KDE_IS_PRELINKED=1

      KDE_NO_IPV6=1

      LANG=en_US.UTF-8

      LD_LIBRARY_PATH=/quovadx/qdx5.6/integrator/clgui/java/lib/i386:/quovadx/qdx5.6/integrator/clgui/java/lib/i386/server:/quovadx/qdx5.6/integrator/lib:/quovadx/qdx5.6/integrator/bin:/quovadx/qdx5.6/integrator/tcl/lib:/quovadx/qdx5.6/integrator/dbms/lib:/usr/lib:/lib:/shlib:/usr/shlib

      LESSOPEN=|/usr/bin/lesspipe.sh %s

      LOCKMGR=lm_qdx5.6_hcitest

      LOGNAME=hci

      LS_COLORS=no=00:fi=00:di=00;34:ln=00;36:pi=40;33:so=00;35:bd=40;33;01:cd=40;33;01:or=01;05;37;41:mi=01;05;37;41:ex=00;32:*.cmd=00;32:*.exe=00;32:*.com=00;32:*.btm=00;32:*.bat=00;32:*.sh=00;32:*.csh=00;32:*.tar=00;31:*.tgz=00;31:*.arj=00;31:*.taz=00;31:*.lzh=00;31:*.zip=00;31:*.z=00;31:*.Z=00;31:*.gz=00;31:*.bz2=00;31:*.bz=00;31:*.tz=00;31:*.rpm=00;31:*.cpio=00;31:*.jpg=00;35:*.gif=00;35:*.bmp=00;35:*.xbm=00;35:*.xpm=00;35:*.png=00;35:*.tif=00;35:

      MAIL=/var/spool/mail/hci

      MANPATH=/quovadx/qdx5.6/integrator/man:/quovadx/qdx5.6/integrator/tcl/man:/quovadx/qdx5.6/integrator/dbms/man:

      OLDPWD=/

      PATH=/quovadx/qdx5.6/integrator/hcitest/bin:/quovadx/qdx5.6/integrator/hcitest/scripts:/quovadx/qdx5.6/integrator/bin:/quovadx/qdx5.6/integrator/contrib:/quovadx/qdx5.6/integrator/sbin:/quovadx/qdx5.6/integrator/dbms/bin:/quovadx/qdx5.6/integrator/tcl/bin:/quovadx/qdx5.6/integrator/clgui/bin:/quovadx/qdx5.6/integrator/clgui/java/bin:/quovadx/qdx5.6/integrator/usercmds:/usr/bin:/etc:/usr/sbin:/usr/ucb:/home/hci/bin:/usr/bin/X11:/sbin:.:/usr/local/bin:/usr/local/scripts:/bin

      PWD=/env_test

      RDSDLL=/quovadx/qdx5.6/integrator/bin

      RDSLOGIN=cl_qdx5.6_hcitest

      SHELL=/bin/bash

      SHLVL=1

      SHXMON_INTERVAL=5

      SSH_ASKPASS=/usr/libexec/openssh/gnome-ssh-askpass

      SSH_TTY=/dev/pts/2

      TCL_LIBRARY=/quovadx/qdx5.6/integrator/tcl/lib/tcl8.4

      TCLX_LIBRARY=/quovadx/qdx5.6/integrator/tcl/lib/tclx8.4

      TERM=xterm

      TIX_LIBRARY=/quovadx/qdx5.6/integrator/tcl/lib/tix4.1

      TK_LIBRARY=/quovadx/qdx5.6/integrator/tcl/lib/tk8.4

      USER=hci

      _=/usr/bin/env

Viewing 22 reply threads
  • The forum ‘Cloverleaf’ is closed to new topics and replies.

Forum Statistics

Registered Users
5,117
Forums
28
Topics
9,292
Replies
34,432
Topic Tags
286
Empty Topic Tags
10