http://qs321.pair.com?node_id=781526


in reply to Re^2: system call in crontab
in thread system call in crontab

I don't know anything about what "/usr/bin/feh" does or how it works. I've never heard of it before. But you say you are able to run it (and run the perl script that runs it via "system()") using your shell (though not via cron). So I'm hoping you know what it does.

If you do the shell command "env" (which will list all your environment variables), do you see anything that seems to relate to this "feh" program (e.g. any variables that have "feh" or "FEH" as part of the variable name)? Is there a man page for "feh" that explains the environment setup for using it?

If, for example, your normal login-shell environment includes a variable like FEH_CONFIG=... then your perl script just has to include a line like:

$ENV{FEH_CONFIG} = ...;
to match whatever is in your shell environment. The point is that cron only runs jobs under a limited shell, leaving out a lot of settings that you might take for granted in your interactive login sessions.

Just for grins, try running a cron job that just does "env", to see what is in your run-time environment under cron. Or if you like, you could have cron run a perl script like this:

#!/usr/bin/perl print "$0: Environment\n"; print " $_ = $ENV{$_}\n" for ( sort keys %ENV );
Comparing that output to what you get from an interactive shell might be informative.