0 like 0 dislike
151 views
asked by (2k points)  
edited by

Please log in or register to answer this question.

1 Answer

0 like 0 dislike
answered by (2k points)  

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

                            (OR)

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 &
         (OR)
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 jobs.

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.

  1. From the command prompt, just run screen. This will give you a new subshell.
  2. Run your desired program
  3. 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.
  4. You can then list the available screen sessions by running "screen -list"
  5. 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.

Related questions

0 like 0 dislike
0 answers
0 like 0 dislike
1 answer
0 like 0 dislike
0 answers
0 like 0 dislike
1 answer
Welcome to Discussion Forum where you can ask questions and receive answers from other members of the community.
...