Gerard Seibert wrote:

I have asked many dumb questions before, and this will no doubt add to
the list.

Scenario:

I start a program from CRON. As an example, let us use
/sysutils/portmanager. Now this program is being run in the background.
How do I get it to run in the foreground so that I can view what it is
doing, and or stop it if I want to? If I succeed in that maneuver, can I
place it in the background again?
I'm not aware of any way to do what you are asking, though maybe it can be done though /proc, I'm not sure. See man procfs if you want to experiment.

Instead, why don't you make the cron job redirect output to a file e.g.
   /sysutils/portmanager 2>&1 | tee /tmp/portmanager

That way you can do a tail -f on /tmp/portmanager and still get the output mailed you as normal. If you don't want to be mailed the output then just use > in place of | tee.

If more than one such job might run at once then you'll have to find some way to name the file differently for each run. Calling it /tmp/portmanager.$$ would probably work as each invocation should be run using a different shell process. I haven't tested this :-(

--Alex

PS Background isn't really an accurate description of the process running from cron. What you are trying to do is to see STDOUT and STDERR from some process which is unrelated to the interactive shell you are running. A background process, as you've probably come across it, is a process run from your shell but which doesn't stop you interacting with the shell. In this case the shell is able to send STDOUT and STDERR from the process to your terminal, but the job run from cron has no such terminal. A better description would be a daemon. Probably not explained very well, and no doubt someone can correct the details.

_______________________________________________
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[EMAIL PROTECTED]"

Reply via email to