Expect script doesn't work under crontab

Hi All,

Using Expect script when I run it manually it works. But when I put the entry in crontab, the job is still running after 15 hours. The script was created as root. I don't think it's a permission issue. Any idea?

This is what I have under root crontab...

00 18 * * 1-5 /home/citi/scripts/citi_auto2.sh /var/cron/log 2>> /var/cron/log

Thanks.

the presense of /var/cron/log twice in your command line is probably a problem.

Do you mean to redirect both stdout and stderr to /var/cron/log?

If so:

/home/citi/scripts/citi_auto2.sh > /var/cron/log 2>&1

Or to append both:

/home/citi/scripts/citi_auto2.sh >> /var/cron/log 2>&1

Thanks, I will try that and get back to you.

I updated crontab but still it's not working. I have waited over 30 minutes already.

When I do grep for the process I see this...

ps -ef |grep auto2
root 471 470 0 12:23:00 ? 0:00 /usr/local/bin/expect -f /home/citi/scripts/citi_auto2.sh
root 552 328 0 12:48:15 pts/1 0:00 grep auto2
root 470 413 0 12:23:00 ? 0:00 sh -c /home/citi/scripts/citi_auto2.sh >> /var/cron/log 2>&1

Also, I got email after running the script...

Your "cron" job on web07
/home/citi/scripts/citi_auto2.sh

produced the following output:

spawn /usr/bin/sh

Any idea?

whats in /home/citi/scripts/citi_auto2.sh ?
Are all the variables set? If when you execute the script it works and not in cron, you should first suspect your environment with something not set...