How to run a program, one after another [closed] - linux

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 8 years ago.
Improve this question
I'm running many programs (all written in fortran). Right now I'm running one program (./first) but I would like that once it is finished another one starts running (./second), and once that other program finishes the next one starts (./third) and so on. Any idea how can I do that from the terminal? Thanks!

how about
./first && ./second && ./third
or
./first ; ./second ; ./third
in the first case, the chain is interrupted, if one of the programs fails (exits with exit code != 0). in the second case, the applications keep on running, even if one of them (e.g. ./second) is going to fail.

Assuming you're using bash or a compatible shell:
Put first in the background by pressing Ctrl-Z (not necessary if it's already backgrounded)
Run wait && ./second && ./third

Related

How to stop a c++ code from running [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 5 years ago.
Improve this question
I clicked on a.out of a code in Linux, now I want to stop running code but as I didn't use the terminal, I don't know that how can I stop the code from running. What can I do?
I am running another code from last week.
I can not kill both by turn off the computer because the first code is running from previous week and I don't have time to run it again
So, if you're running two instances of a.out (which I'm just assuming because your question is unclear...) then, as other users have said, run:
pgrep a.out
If the second a.out process is the one you want to kill, take the larger PID number (in your case it seems to be 19564) and run:
kill 19564

What is the easiest way to create a script that runs on the next reboot only? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 7 years ago.
Improve this question
I am looking to create a script that executes on the next reboot only (not each reboot).
For example, I have script test.sh:
cd /tmp
touch toto.txt
What is the easiest way to execute this script only on the next reboot?
By easiest I mean : minimal number of commands, and independent of the linux OS/Version (if possible).
After several searches I found I can use the init.d system. But I think that's not the best way, because my script must run only once.
Add something like
LOCKFILE=/var/lock/test_sh_done
if [ ! -f ${LOCKFILE} ]; then
touch ${LOCKFILE}
/path/to/test.sh
fi
to /etc/rc.local, and make sure that /etc/rc.local has the execute bit set. If you want to run it again at the next reboot, just delete the LOCKFILE.

at: how to schedule a job to run at one second later? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 8 years ago.
Improve this question
I want to use the command "at" to schedule a job to run at one second (or minute/hour) later. If using "-t" option, then it involves with the hassle of getting the current time etc. Is there any easy way out?
But don't suggest me to use "sleep", because the current process will exit.
Thanks for the tip.
The at program can take now+ a time unit (e.g. now+1minute) as a timespec. You won't get finer time resolution than one minute with at.

Executing a few commands in bash once an executable closes? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 8 years ago.
Improve this question
I have an application that will shut itself down at a specific time, is there a way for a bash script to execute some commands (like move log files, clean temp files) after the application has closed then restart it?
It's possible to reinvent this wheel, though not at all a good idea.
This can be as simple as:
while :; do
./run-your-process
do-some-cleanup
done
But really -- don't. Use runit, upstart, daemontools, systemd, supervisord, or one of the many, many other tools which will automate this process for you.
If you start the main process in your script in the background, you could turn on job control in bash with 'set -bm' and then trap SIGCHLD and do your cleanup and restart in the signal handler.
#!/bin/bash
set -bm
childexit() {
... cleanup and restart
}
trap 'childexit' SIGCHLD
mainprocess &

Linux task in the background finishes [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 8 years ago.
Improve this question
I have got a Linux task that finishes and prints:
[6]- Done
I have noticed that in the past it would print:
[6]+ Done
Is there any difference between + and -?
man bash states:
In output pertaining to jobs (e.g., the output of the jobs command), the current job is always flagged with a +, and the previous job with a -.
Therefore, the command with '+' is the most recent command sent to the background.

Resources