A script may be run in the background from the command line like this:
$ ./myscript.sh &
In other words, append &
to the command.
You've said you want to run this script "without showing the termial". I think there are two ways to do this:
create a systemd
service - as in this answer
start the script as a cron
job when the system boots:
To set up a cron
job, you will need to create a new crontab
entry.
To do this, open a terminal, and type the following command:
$ crontab -e
This will open your crontab
in an editor (nano
is a good choice for editor). When you are in the editor, add the following line to the bottom of the file:
@reboot /home/user/myscript.sh & >> /home/user/myscript.log 2>&1
Where /home/user/myscript.sh
is the full path to your script file. Any output from your script will be redirected to the file at /home/user/myscript.log
. Be sure to check this logfile for any error messages.
Save the file ( ^ o
) if using nano
, and exit the editor ( ^ x
).
Some things to remember:
Make sure myscript.sh
is executable.
If you use any commands in myscript.sh
, make sure the system knows where to find them - i.e. use a full path to the command, or declare a PATH in your script.
Let us know if you have further questions (post a comment) & we'll try to help.