Drop Down MenusCSS Drop Down MenuPure CSS Dropdown Menu

How to run a script at background and How to monitor and how to shedule a job using crontab easily ?

 By giving" &" at end of script called running background


Set in task scheduler or crontjob.

Using at command you can schedule a job to run at a particular date and time. For example, to execute the backup script at 5 a.m tomorrow, do the following.

$ at -f backup.sh 5 am tomorrow

you can run the shell script Following methods at backgroundly:

. script.sh &
./script.sh &
sh script.sh &
nohub sh script.sh &
nohub ./script.sh &
nohub .script.sh &

Note: hup is a hangup signal... nohup - no hangup... so if we give  nohup script.sh & ... it starts progressing script.sh in back ground... that the subsequent logout or session disconnection does not stop..

Note: & Stands for running background

After running this give  "ctrl+z" in background one id will be displayed as running that is called  process_ID using that PID we can adjust priority for that particular jobs.

jobs -l (will display that process id which is running )

Note: jobs will be displayed only the running and stopped jobs for only that session

top -c is also one of option -c means which display the commands. But This will be displayed whole server jobs and services not for session only

if you want commands

screen Sh script.sh

Here are the steps you can follow to run a process in screen, detach from the terminal, and then reattach.

From the command prompt, just run screen. This will give you a new subshell.

Run your desired program

Detatch from the screen session using the key sequence Ctrl-a Ctrl-d (note that all screen key bindings start with Ctrl-a). This will drop you back to your original shell and display a message "[detached]", indicating that the screen session is still running.

You can then list the available screen sessions by running "screen -list"

You can reattach to this screen session by running "screen -r". Once reattached, you will be able to take off where you left off and see any output that was printed to the screen during the time that you were detached. If you have multiple screen sessions, then you can specify the tty name (as displayed by screen -list) as an argument to screen -r to attach to a particular session.


Popular posts from this blog

How to Get Table Size, Database Size, Indexes Size, schema Size, Tablespace Size, column Size in PostgreSQL Database

7 Steps to configure BDR replication in postgresql

How to find the server is whether standby (slave) or primary(master) in Postgresql replication ?

PostgreSQL Monitoring Tools

PostgreSQL pgBadger