Find the answer to your Linux question:
Results 1 to 7 of 7
Hi, I have a script that I cannot seem to get working in cron. The first job is the one not running, the second is another job as a sanity ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Feb 2013
    Posts
    5

    crontab not running script


    Hi,
    I have a script that I cannot seem to get working in cron. The first job is the one not running, the second is another job as a sanity check that does run. If I run the command verbatim from the terminal manually, it works fine. The snap.exp file is set to 755 and is in /home/jsnap. Here's the code...

    Code:
    10 18 27 * * root cd /home/jsnap; ./snap.exp cronsnap username password host compare
    09 18 27 * * root cd /home/jsnap; touch ./myfile
    I have run the crontab -l command and tried to run my job from here, but it doesn't work either.

    Any ideas?

    Thanks,
    -T

  2. #2
    Just Joined!
    Join Date
    Sep 2012
    Location
    Nashville, TN
    Posts
    93
    can you post output from /var/log/cron? It should have some details about what is causing the error.

  3. #3
    Just Joined!
    Join Date
    Feb 2013
    Posts
    5
    I'm only seeing two types of messages in the logs. I've got a couple files full of these. About 20 of the following...

    Feb 27 19:34:35 sparky-0256032011000016 /usr/bin/crontab[7988]: (root) LIST (root)

    Then one of the following and another series of the message above. With different process numbers, time.

    Feb 27 19:35:01 sparky-0256032011000016 crond[7931]: (root) CMD (usr/nma/bin/writeLogCronJob)

    This message occurs at consistent 1 min intervals.

    Thanks,
    -T

  4. #4
    Just Joined!
    Join Date
    Feb 2013
    Posts
    5
    Here are some additional messages after trying to run the job after adding it using "crontab -e". The command didn't execute as expected, but there is some info in the logs. I've omitted the user/timestamps since I needed to transpose this manually, its same as above. This happened over a period of 10 seconds.

    Code:
    /usr/bin/crontab[30325]: (root) LIST (root)
    crond[10097]: (root) RELOAD (cron/root)
    crond[10097]: (root) Unauthorized SELinux context, but SELinux in permissive mode, continuing (cron/root)
    crond[30523]: (root) NULL security context for user, but SELinux in permissive mode, continuing ()
    crond[30524]: (root) CMD (set $PATH=/usr/jawa/bin:/usr/jawa/jsnap; cd /home/jsnap; ./snap.exp cronsnap username password host compare)
    crond[30525]: (root) CMD (/usr/nma/bin/writeLogCronJob)
    /usr/bin/crontab[30598]: (root) LIST (root)
    /usr/bin/crontab[30876]: (root) LIST (root)
    /usr/bin/crontab[31115]: (root) LIST (root)
    crond[30523]: (root) MAIL (mailed 221 bytes of output 
    /usr/bin/crontab[31365]: (root) LIST (root)

    -T

  5. #5
    Just Joined!
    Join Date
    Sep 2012
    Location
    Nashville, TN
    Posts
    93
    Can you check if allow_execmode = 1? If it is not can you change it to 1.

  6. #6
    Just Joined!
    Join Date
    Feb 2013
    Posts
    5
    I've determined the system IS running the command, I can have it output to a file. However, the script itself is not running completely through. I only get the follow line output to the file.
    Code:
    spawn jsnap --snap cronsnap -l username -t host2 jsnap-compare
    If I run it manually, I see the following...
    Code:
    spawn jsnap --snap cronsnap -l username -t host2 jsnap-compare
    username password:
    Connecting to username@host2 ...
    CONNECTED.
    EXEC: 'show route" ...
    <output omitted>
    Here is the expect script...

    Code:
    # !/usr/bin/expect
    
    set timeout 20
    
    set snap [lindex $argv 0]
    set login [lindex $argv 1]
    set pass [lindex $argv 2]
    set host [lindex $argv 3]
    set file [lindex $argv 4]
    
    spawn jsnap --snap $snap -l $login -t $host $file
    
    expect "ssword:"
    send "$pass\r"
    
    interact

  7. #7
    Just Joined!
    Join Date
    Feb 2013
    Posts
    5

    Solved Issue

    I've finally rooted out the issue. It was a PATH problem, nothing to do with cron.

    The expect script was calling a program called jsnap. Jsnap required paths to a couple executables. I didn't realize that cron removes the environment variables from the calling user, root. So what I did is set the PATH variable in the expect script to include those directories. In my case it came out as...

    set env(PATH) /usr/bin:/bin:/usr/jawa/bin

    After doing this it ran like a champ.

    Thanks for your help.

    -T

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •