I have a Unix shell script program that wants to run in the foreground terminal window. It runs fine in there, but it requires that the terminal always be open.
I want to run it as a background/service application so I do not have to keep logged in.
I want to run a Unix shell script in the background not a terminal window?
the command is
crontab -e
Look it up on the Internet on how to put an entry here to enter in a scheduled task.
RJ
Reply:Two things to do...
(1) You need to re-direct both the input and the output so it doesnt crash on you if it actually does require a terminal to be open while running. Typically, shorting them to /dev/nul or having some preset text files with some bogus inputs and something to grab the output may work. UNLESS the program is CURSES aware or an X-Windows or similar program - then you need to run it in a virtual x-windows windows that is not attached to a physical monitor of any kind.
(2) Add an ampersand (%26amp;) at the end of the command to make it run in the background, OR if you have superuser rights, put it into your crontab to run at specific time or times during the day.
Reply:add an ampersand (%26amp;) to the end of the command
Reply:Since you want to log out, you need to run:
nohup %26lt;command%26gt; %26amp;
Background jobs tend to terminate otherwise when you logout. Run man nohup for the grisly details.
Reply:Run the program you want running in the background like normal. Hold down ctrl+z in the terminal. This will stop the process currently running. Now type bg and hit enter. This will cause the last stopped process to run in the background.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment