Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Crontab and Xvfb 1

Status
Not open for further replies.

Masali

Programmer
Jun 19, 2002
143
0
0
SE
I have a problem that I just don't get...

I use boutell.com's program webthumb, that makes thumbs from websites by opening Mozilla in a Xvfb and copies the content to a PPM-file.

If Xvfb is not started, it automatically starts this, and the same with Mozilla. I have modified the program slightly so it also adds a row to a database.

When I run this program as root, everything works fine, the thumb is created as a jpg and database is written.

But when I add this as a crontab job for root, it doesn't work. The database gets written to, but the thumb is not created. How can this be? Is there some difference between running Xvfb as root or as Crontab root?

The script that is run from crontab is a PHP-script that calls a Perl-script using function "passthru".

The Perl script just takes a couple of commands and forwards them to boutell's webthumb.

Code:
#!/usr/bin/perl

if (int(@ARGV) != 4) {
	die "Usage: makethumb [URL] [Max Width] [Max Height] [Filename (without .jpg)]\n";
}
my $url = $ARGV[0];
my $w = $ARGV[1];
my $h = $ARGV[2];
my $f = $ARGV[3];

my $sys="./webthumb $url | pnmcut -top 108 -left 3 -right 1005 -bottom 990 | pamscale -xyfit $w $h | pnmtojpeg > thumbs/$f.jpg";
system($sys);

Boutell.com's webthumb script can be looked at here.

Thanks in advance from a confused
Masali
 
Masali - ensure that your $PATH and other environment variables used when running interactively are passed to cron in the script. cron uses a very limited set of environment variables if left to it's own devices. HTH.
 
Perfect! I changed all paths to absolute and it worked like a charm! Thanks! Gotta think about that in the future...
 
Excellent and thanks for the star! I don't think there are many people in the unix world who haven't been caught out by that at some stage.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top