2

How can I run the following command/process in background immediately after starting it:

zip -r file.zip directory/*

What I actually want to do, is to run the zip process working even after exiting / disconnecting from the terminal - just like the -b option in wget

1
  • zip -r file.zip directory/* &
    – suspectus
    Nov 15, 2014 at 12:40

2 Answers 2

0

What I actually want to do, is to run the zip process working even after exiting/disconnecting from the terminal

Let me ignore the 'zip' part.

To continue to run any program after disconnecting from the terminal, either:

  1. Run in the background and disown.
  2. Use TMUX
  3. Use screen.
2
  • What if I just put the process in background by adding an & at the end of the command (zip -r file.zip directory/ &) and then exit the terminal without disown?
    – Phoenix
    Nov 15, 2014 at 13:11
  • If you do that (or fire it up and then use <kbd>Control</kbd><kbd>z</kbd>bg %1) then it might get killed when you exit the shell. Might since this is an option which can be set in the shell. E.g. see shopt. (shopt -s huponexit) for bash and setoptHUP for zsh).
    – Hennes
    Nov 15, 2014 at 13:43
1

To run process in background you need to add nohup at the end of process and end it with & so the command will be like this

nohup zip -r file.zip directory/* &

and to see the running process in background run this command

jobs

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .