Koozali.org: home of the SME Server

Problems running bash script via crontab

nb69

Problems running bash script via crontab
« on: September 16, 2005, 12:40:09 AM »
Hello,

I'm running SME 6.01.

I've got a crontab entry that runs a script to extract various RSS feeds and write to an HTML file.

My Contrab Entry looks like this:

Code: [Select]

/home/e-smith/files/ibays/rss/html/donow >> /dev/null 2>&1


The actual script for "donow" is :

Code: [Select]
/usr/bin/php -q /home/e-smith/files/ibays/rss/html/crawlrss.php > /home/e-smith/files/ibays/rss/html/index.html


It runs every 4 hours ok. And the html file is created. But there is no content.

When I run the script from the shell, got no problems. Even when I "sudo -u root" its ok from the shell.

Anyone know why cron is having problems?

Thanks!

Offline CharlieBrady

  • *
  • 6,918
  • +3/-0
Re: Problems running bash script via crontab
« Reply #1 on: September 16, 2005, 02:27:34 AM »
Quote from: "nb69"

I've got a crontab entry that runs a script to extract various RSS feeds and write to an HTML file.

My Contrab Entry looks like this:

Code: [Select]

/home/e-smith/files/ibays/rss/html/donow >> /dev/null 2>&1

...

When I run the script from the shell, got no problems. Even when I "sudo -u root" its ok from the shell.

Anyone know why cron is having problems?


Remove the redirection of error output to /dev/null and you will probably find out.

nb69

Problems running bash script via crontab
« Reply #2 on: September 16, 2005, 04:56:47 AM »
Hi ,

thanks for the reply. I removed the redirection. Not getting any messages. And the html is not not being build by cron.

Any thoughts?

Offline CharlieBrady

  • *
  • 6,918
  • +3/-0
Problems running bash script via crontab
« Reply #3 on: September 16, 2005, 05:21:30 AM »
Quote from: "nb69"

Any thoughts?


Try:

env - /usr/bin/php -q \
  /home/e-smith/files/ibays/rss/html/crawlrss.php

nb69

Problems running bash script via crontab
« Reply #4 on: September 16, 2005, 06:00:57 PM »
Hi,

ok, tried that command. Now it no longer works from the shell :(

nb69

Problems running bash script via crontab
« Reply #5 on: September 16, 2005, 08:22:46 PM »
Now, I've changed permissions to all the php files to have execute on. And now it works from the shell again. I just don't get it. It works perfectly on another server (debian based) without all this hassle.

But as soon as cron executes it, it creates an incomplete html file.

nb69

Problems running bash script via crontab
« Reply #6 on: September 16, 2005, 08:43:59 PM »
If anyone wants to give the script a try you can grab it from here:

http://lastrss.webdot.cz/

Its a pretty cool RSS php class.

Thanks.