Cron job behaving strangely

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • bsamer
    New Member
    • Mar 2010
    • 1

    Cron job behaving strangely

    Well very simply i have a script when i run it manualy from the root it will work but from the crontab. I get an error

    The problem is from root i run the script which will define all the env. var. all the needed things and the adabas utility for backup adabck will do its thing and dump the db to a file..all well but...

    Why the hell is it giving an error from the cron.. it is loading all the same var. it is running the same script which loads all the same env. var. ... im not sure..

    here is the moust simplified script i have used it was larger and more complex but when i started trouble shooting i eliminated all the parts and striped it down to the basic pars needed to run...

    this is the backup script that fails... as you will c all the env. var.(sag.profil e , assign.bsh) are loaded.. and they do work when i run it man.

    Code:
    [I]#!/bin/sh
    db=DB2
    . /usr/local/bin/sag.profile
    db=DB2
    BCK001=/backup_disk2/db2.todisk
    export BCK001
    . /SAG/ada/db002/assign.bsh
    adabck DB=2 DUMP=* NEW_PLOG 2>&1[/I]
    When i run it in crontab:

    Your "cron" job on sun--
    /usr/games/mydb2

    produced the following output:

    stty: : No such device or address
    [Setting environment for Adabas Client]
    [done]
    [Setting environment for Adabas]
    [done]
    [Setting environment for Natural]
    [done]
    [Setting environment for Natural Security]
    [done]
    Reading Merlin Environment
    /usr/games/mydb2: test: unknown operator a


    ok i get the no stty... cant that be an issue can i redirect or what?
    where did he get test? why don't i ever get this error when i run it manually?

    i can c only ... stty is different... the env. i think is the same..(when manually running and from cron)..


    This is the normal output when i run the script manually:

    [Setting environment for Adabas Client]
    [done]
    [Setting environment for Adabas]
    [done]
    [Setting environment for Natural]
    [done]
    [Setting environment for Natural Security]
    [done]
    Reading Merlin Environment
    %ADABCK-I-STARTED, 07-MAR-2010 12:36:42, Version 6.1.8.01 (Solaris 64Bit)
    %ADABCK-I-DBON, database 2 accessed online

    %ADABCK-I-BKSAVE, saving container ASSO1
    ........and so on...
  • Hydaral
    New Member
    • Jun 2010
    • 24

    #2
    Are you specifying the user in the crontab?

    eg:
    Code:
    * * * * * root [command]

    Comment

    • numberwhun
      Recognized Expert Moderator Specialist
      • May 2007
      • 3467

      #3
      Originally posted by Hydaral
      Are you specifying the user in the crontab?

      eg:
      Code:
      * * * * * root [command]
      @Hydaral Cron scripts are inherently run as root. Personally I am not aware that you can specify a user to run them as.

      Comment

      • Hydaral
        New Member
        • Jun 2010
        • 24

        #4
        It's only used in the system-wide crontab, it's not required for user-specific crontabs, they are run under that user's account.

        Comment

        • numberwhun
          Recognized Expert Moderator Specialist
          • May 2007
          • 3467

          #5
          Personally, as a rule, I have never used the user specific crontab. For security purposes (and because only root can access certain resources) I stick strictly to the system cron. So, if root it needed, plop this in the system cron and see if it works instead of trying to specify root

          Comment

          Working...