17 Mart 2019 Pazar

fg komutu

Giriş
Arka plandaki (background) bir işi ön plana (foreground) getirir.  
- İşi arka plana atmak için Ctrl +Z kullanılır
- Arka plandaki işleri görmek için jobs komutu kullanılır. 
- Arka plandaki işi indeks numarası ile öldürmek için kill komutu kullanılabilir.

Örnek
Bir soru ve cevap şöyle. Burada uygulama terminalde başlatılıyor. Penceresi açıldıktan sonra Ctrl + Z ile arka plana gönderiliyor. Bu durumda artık çarpıya basarak kapatılamıyor. Kapatabilmek için önce fg komutuyla tekrar ön plana getirilmesi lazım
Q: I opened imagemagick through the terminal with $ display filename.jpg

Once it opened, the terminal was in use (?) as in no more prompt, just blank space where I could type anything like when you write to a file with 'cat'. I used CTRL + Z to get back to the prompt and the image stayed open in imagemagick. Now I can't close it - clicking the red X on the window doesn't do anything. How do I close this window/program?

A : type fg in the terminal to bring the stopped job back to the foreground. Then the red X should work again.

fg İle Kullanılacak Sayıyı Bulmak
Açıklaması şöyle.
When you send a process to the background, whether by using ctrl-z or by & at the end of the command, you get an output in the following format: [index] process-id. If you send multiple processes to the background, the index will keep incrementing every time.
Şöyle yaparız
$ sleep 100 &
[1] 41608
$ sleep 101 &
[2] 41609
$ sleep 102 &
[3] 41610
$ sleep 103 &
[4] 41611
$ sleep 104 &
[5] 41612
$ sleep 105 &
[6] 41613
$ sleep 106 &
[7] 41614
jobs Komutu
Örnek
Şöyle yaparız.
$ sleep 123 
[1] 26103
$ jobs
[1]+  Running                 sleep 123 &
$ fg 1
sleep 123
kill Komutu İle İşi Öldürmek
Açıklaması şöyle.
If it is your one and only background job you can kill it with kill %1. If not sure you can list all your background jobs with jobs and use kill %<n> where you replace n by the number of your ping job.
Diğer Örnekler
Örnek
Şöyle yaparız.
fg %2
Örnek
Ctrl + Z ile iş durdurulur. Daha sonra şöyle yaparız.
fg ; echo "Finished successfully!"

Hiç yorum yok:

Yorum Gönder