Skip to main content

UNIX - Process/Jobs


Playing the commands fg , ctrl+z , bg and jobs


In this post I would like to share few basic process or job specific tricks in UNIX.

1. If you want to run a process in bacground just add a & as suffix with a space 

Eg:

[root@localhost kannan]# ruby test.rb &

here this process test.rb will run in background 

2. If you want list available background tasks/processes/jobs , just use the command 'jobs'

Eg:

[root@localhost kannan]# jobs

here the result would be 

[1]+ Running ruby test.rb 

3. If you want to bring a background process in front (foreground) just use fg [#<job number>]

Eg

[root@localhost kannan]# fg #1 

It will bring the above 'ruby test.rb' process in front.

4. If you want to again move a already running process to background , use two combination of commands
    a. First pass Ctrl+Z , here you will get a message like 'stopped' don't get upset, it will just suspend
    b. Do run 'bg' command will take the suspended process/job/task to background process 

Eg

[root@localhost kannan]# jobs
[1]+  Running                 ruby test.rb &
[root@localhost kannan]# fg #1
ruby test.rb
^Z
[1]+  Stopped                 ruby test.rb
[root@localhost kannan]# bg
[1]+ ruby test.rb &
[root@localhost kannan]# 



Comments

Popular posts from this blog

Errno::ENOENT: No such file or directory

HTML to PDF conversion is very easy in rails and pdfkit will be useful in this case, wkhtmltopdf tool will be supporting tool so you can easily convert an html to pdf.  In my experience I used the following steps: gem install pdfkit -v 0.5.0 gem install wkhtmltopdf -v 0.1.2 gem install wkhtmltopdf-binary Some times this sequence will not work, so I use the following as per the instruction from  https://github.com/pdfkit/pdfkit/wiki/Installing-WKHTMLTOPDF Be careful to download the appropriate wkhtmltopdf tar ball, it depends on your os architecture, like i386 or 64 wget http://wkhtmltopdf.googlecode.com/files/wkhtmltopdf-0.9.9-static-amd64.tar.bz2 tar xvjf wkhtmltopdf-0.9.9-static-amd64.tar.bz2 mv wkhtmltopdf-amd64 /usr/local/bin/wkhtmltopdf chmod +x /usr/local/bin/wkhtmltopdf Try to convert html to pdf after restarting your web servers.  If you get any error like: Errno::ENOENT: No such file or directory then I have a straightforward method and

Rails 1.2.1 with Ruby 1.8.x installation tips

ROR Setup (Ruby 1.8.6 , patch level 111, rails 1.2.1, CentOs 6.2 62 bit, Postgres 8.3) Make sure rpmforge included in your yum.repo ‘s, you can make it is available through cd /tmp/ wget  http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm rpm --import  http://apt.sw.be/RPM-GPG-KEY.dag.txt rpm -K rpmforge-release-0.5.2-2.el6.rf.*.rpm rpm -i rpmforge-release-0.5.2-2.el6.rf.*.rpm Download and install ruby 1.8.6 cd /tm/ wget ftp://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.6-p111.tar.bz2 tar jxf ruby-1.8.6-p111.tar.bz2  cd ruby-1.8.6-p111 ./configure make Note: If you found any error like make gcc -g -O2  -DRUBY_EXPORT -D_GNU_SOURCE=1  -I. -I.  -c array.c gcc -g -O2  -DRUBY_EXPORT -D_GNU_SOURCE=1  -I. -I.  -c bignum.c gcc -g -O2  -DRUBY_EXPORT -D_GNU_SOURCE=1  -I. -I.  -c class.c gcc -g -O2  -DRUBY_EXPORT -D_GNU_SOURCE=1  -I. -I.  -c compar.c gcc -g -O2  -DRUBY_EXPORT -D_GNU_SOURCE=1  -I. -I.  -c dir.c