08 February 2010

Ubuntu Background Process

หลังจากย้าย Bot อัพเดทหน้าข้อมูลดาต้าเบสจาก windows server 2008 มา Ubuntu เจ้าบอทตัวน้อยเลยต้องหา background process ที่ใหม่อยู่ด้วย โดยใน Ubuntu นั้นทำได้ง่ายยยยยยยยยยยย โค ตะ ระ เลย เพียงแค่ใส่ & ต่อท้ายเข้าไป อย่างเช่น

root@ubuntu:~# firefox &
[3] 19101

เท่านี้เจ้าหมาย่างก็กลายไปอยู่ background แล้วหุหุ สำหรับการตรวจดุว่ามี อะไรรันอยู่บ้างก้พิม jobs ไป

root@ubuntu:~# jobs
[1]- Stopped php /root/web_bot/bot_php.php
[2]+ Stopped php /root/web_bot/bot_startup.php
[3] Done firefox

สำหรับ Process ที่ขึ้น Stopped นั้นสามารถทำให้เป็น Running โดยพิม bg [jobspec] jobspec ก็คือเลขที่อยู่หน้าสุดนั้นแหละครับ

root@ubuntu:~/web_bot# bg 1
[1]+ php bot_php.php &

ถ้าหากอยากทำให้กลับมาอยู่ foreground ก็ใช้คำสั่ง fg [jobspec]

root@ubuntu:~/web_bot# fg 1
php bot_php.php


ลองๆไปเล่นกันดูนะคับ ^^
สำหรับข้อมูลเพิ่มเติมก็ไปที่ http://www.watchingthenet.com/ubuntu-tip-how-to-launch-programs-in-the-background-from-a-terminal-window.html

0 comments:

Post a Comment