Run Linux Commands in Background
Why Run Commands in Background?
Ketika menjalankan perintah di Linux, terkadang kita ingin menjalankannya di latar belakang agar terminal tetap responsif. Berikut adalah beberapa cara untuk melakukannya.
Using &> /dev/null &
Example:
ping 8.8.8.8 &> /dev/null &
This command runs ping in the background and redirects both standard output and standard error to /dev/null, effectively silencing any output.
To show the running process, we can use jobs command.
Using nohup with &> /dev/null &
Example:
nohup ping 8.8.8.8 &> /dev/null &
This command uses nohup to run ping in the background, allowing it to continue running even if the terminal is closed. The output is also redirected to /dev/null.
To show the running process, we can use jobs command.
Terminate the process with kill -9 pid_num.
💬 Komentar
⏳ Memuat komentar...
Tulis Komentar