Nohup Command Di Linux

Nohup adalah Task yang dijalankan oleh command prompt linux namun bedanya kita menjalankan command nya pada saat remote. Jadi kita ingin command tersebut jalan terus walaupun sudah di close/di tutup remote linuxnya. Dalam demo kali ini saya akan menjalankan command prompt linux nya.

Syntak

nohup command [command-argument ...]

Atau kita bisa melihat helper apa saja syntak argument yang tersedia

nohup --help | --version

Keterangan

--version Untuk Melihat Versi Dari Nohup
--help Untuk Melihat Argument apa saja yang tersedia dalam nohup
# nohup --version
nohup (GNU coreutils) 8.22
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by Jim Meyering.
​
# nohup --help
Usage: nohup COMMAND [ARG]...
  or:  nohup OPTION
Run COMMAND, ignoring hangup signals.

      --help     display this help and exit
      --version  output version information and exit

If standard input is a terminal, redirect it from /dev/null.
If standard output is a terminal, append output to 'nohup.out' if possible,
'$HOME/nohup.out' otherwise.
If standard error is a terminal, redirect it to standard output.
To save output to FILE, use 'nohup COMMAND > FILE'.

NOTE: your shell may have its own version of nohup, which usually supersedes
the version described here.  Please refer to your shell's documentation
for details about the options it supports.

GNU coreutils online help: <http://www.gnu.org/software/coreutils/>
For complete documentation, run: info coreutils 'nohup invocation'

Kita test ya dengan menjalankan script 

 # nohup sh test.sh > Output.out 2> Error.err < /dev/null &

Maka setelah kita menjalankan nohup sample outputnya seperti ini

]# nohup sh test.sh > Output.out 2> Error.err < /dev/null &
[1] 3531

Backround terminal secara langsung mejalankan script sesuai isi perintah yang ada dalam test.sh maka untuk melihatnya. Script test.sh sata isi script seperti berikut ini :

#!/bin/bash
mkdir testing_no_hup

Setelah dijalankan maka akan membuat sirectory mkdir testing_no_hup. Didalam perjalanan saya butuh menjalankan beberapa command sekali execute. Karena setelah saya cek no_hup itu hanya sekali execute jadi ketika kita butuh multiple exceute command maka contoh nya seperti ini.

nohup `sh test.sh && sh test1.sh` > Output.out 2> Error.err < /dev/null &

Dengan menjalankan syntak diatas maka akan secara otomatis menjalankan syntak 2 command perintah.

testing_no_hup
testing_no_hup_1

Demikianlah artikel kali ini, tentang nohup pada Linux. Semoga bermanfaat artikel kali ini.

Related Articles

Comments