Next Previous Contents

4. The Problem

4.1 Cron's environment

When a user submits a job with cron, their environment is not preserved. This is reasonable since cron jobs are typically ongoing and may be adversely affected if the user's environment changes subsequent to the cron submission. Thus, a cron job should call a script that set's up the correct environment before starting the user's desired program. The 'at' command does this nicely.

4.2 Interactivity

When a job is started with cron, it runs as a background process. No interaction with the program is possible (unless it is capable of interacting via a FIFO or some such) except termination via its pid. The only program that I know of that allows such interaction and serves as a wrapper for other prrocesses is 'screen'

4.3 Screen

There's one little problem with screen though. It expects to attach to a terminal when it first starts. This won't happen under cron so screen will fail. Fortunately, screen comes with a "start detached" option.


Next Previous Contents 1