Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Cron job not running at all (shell script)  (Read 4675 times)

0 Members and 1 Guest are viewing this topic.

dend

  • Guest
Cron job not running at all (shell script)
« on: May 18, 2007, 08:34:45 AM »
I am trying to setup a cron job but cannot get it to run at all. I have a shell script I want to run and like many others, I can get it to run from the command line but not through cron. I have tried all suggestions I can find but they don't seem to make any difference.

The job I have is:
23 15 * * * /home/sde/sdecompress/sde_shutdown.sh > /home/sde/sdecompress/sde_sh
utdown.log

Running sde_shutdown.sh on its own is fine, but not that script when its in the cron job. I don't even get the logfile or mail, and I was trying with an error log (i.e. 2>), but still did not get anything. I have a line in my script to echo the date but it doesn't even return that:

#!/bin/ksh
#
# Description:
#
# set -x
#
.profile
echo this is a test
sdemon -o shutdown -p sde -N

The permissions are available (I did a chmod 777 to ensure that) but am at a loss as to how to get it to run. Does anybody know what I am doing wrong?!

My system details are:
AIX 5L Version 5.3 - Unix
There is a cron.deny, without any entries in it.

banjo67xxx

  • Guest
Re: Cron job not running at all (shell script)
« Reply #1 on: May 18, 2007, 08:53:30 AM »
23 15 * * * /home/sde/sdecompress/sde_shutdown.sh > /home/sde/sdecompress/sde_sh
utdown.log

You wont see anything happening at 23:15 as this is set to run at 15:23. For testing purposes set it to * * * * * so it runs every minute.
Another thing to check, does AIX require that /home/sde/sdecompress/sde_shutdown.sh be listed in /etc/shells ?

.profile
echo this is a test
sdemon -o shutdown -p sde -N

Your .profile wont execute within the same shell without a preceding .
All commands should use the full pathname as the context of cron jobs is not the same as that inherited from a login

E.g.
Code: [Select]
. /home/sde/.profile
/usr/bin/echo this is a test
/home/sde/sdecompress/sdemon -o shutdown -p sde -N

dend

  • Guest
Re: Cron job not running at all (shell script)
« Reply #2 on: May 22, 2007, 04:50:24 AM »
Thanks for your reply, I have been out of the office so couldn't post any sooner.

I seem to have a bit more progress now. The script will run (the echo command works), but

The problem seems to be recognising the 'sdemon command'; when I check my mail now it says (path name)/sde_shutdown[7]: sdemon: not found.

If I were using another language it would be straightforward here - enclose it in quotes to get the whole line to run as it has spaces in. Is there a way around this in Unix?

banjo67xxx

  • Guest
Re: Cron job not running at all (shell script)
« Reply #3 on: May 22, 2007, 08:01:29 AM »
Thanks for your reply, I have been out of the office so couldn't post any sooner.

np

Quote
The problem seems to be recognising the 'sdemon command'; when I check my mail now it says (path name)/sde_shutdown[7]: sdemon: not found.

If I were using another language it would be straightforward here - enclose it in quotes to get the whole line to run as it has spaces in. Is there a way around this in Unix?

You can do that in bash/sh on linux/AIX too

Code: [Select]
"/home/sde path name/sdemon" -o shutdown -p sde -N