Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: system call in crontab

by cdarke (Prior)
on Jul 20, 2009 at 07:20 UTC ( [id://781551]=note: print w/replies, xml ) Need Help??


in reply to system call in crontab

Problems with jobs failing to run in cron are almost always because of the environment. Note: these are cron issues and nothing to do with Perl.

Shells call start-up files on initialisation, and they call different start-up files depending on:
a) the shell type, e.g. sh, csh, ksh88, ksh93, bash, behave differently.
b) if this is a logon shell
c) if this is an interactive shell

We have no way of knowing for sure which shell you are using. However, a best guess is that you have a .profile and/or a .kshrc, or maybe .bash_profile and/or .bashrc. If you are using these, then you may need to "source" them before feh will run (that is using the "dot" command : . in sh or ksh, "source" in csh or bash). That would require a shell script containing the "source" command followed by the call to feh.

It would be better to put the environment settings in your perl script instead, but that would require you to actually know which settings are affecting the feh program.

Replies are listed 'Best First'.
Re^2: system call in crontab
by Bloodnok (Vicar) on Jul 20, 2009 at 13:34 UTC
    In all cases, a script, assuming sh/ksh (& csh for all I know), can determine whether the shell is interactive by testing $- - if it contains the i switch, then it's an interactive shell - which is why the following is commonly seen at the end of a users .profile...
    . . case "$-" in *i*) # Interactive shell exec bash ;; *) # Do nothing of the sort - non-interactive : ;; esac
    Otherwise, any attempt to dot the .profile from a non-interactive shell causes the attempt to hang since the newly exec(1)ed shell will be waiting for input.

    Having said that, any job started by cron will always be run non-interactively - such that if any output i.e. either STDOUT or STDERR, is not redirected, it will be mailed to the crontab(1M)s user.

    I'm rather intrigued as to why the OP is attempting to start a GUI program using cron(1M) - if the intent is to create a background image, then .xinitrc or similar is place to start it or alternatively use the background property of the window manager.

    A user level that continues to overstate my experience :-))

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://781551]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (4)
As of 2024-04-16 18:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found