How to Run Tmux Service Scripts on Ubuntu Start Up

Yes, it is not a long memory after doing it countless times. Yesterday I stepped on it again; the startup script written on ubuntu does not execute, it is only a problem of executable permissions and user permissions, and wasted another morning;

Do some work automatically when unbuntu starts. The best practice is:

You want to execute a service

At this time you need to use ubuntu's upstart mechanism

To put it simply, this is a script like this:

123 start on startuptaskexec /path/to/command

Save it as a taskxxx.conf file and place it under the /etc/init directory (this will be started with root user authority when booting);

Or save as ~/.config/upstart (this will start with the current user rights at boot time)

You need to use the systemd service, which we wrote about popular science articles before:

https://happy123.me/blog/2016/08/22/how-to-write-standard-startup-script/

Just want to execute a simple command

1 sudo nano /etc/rc.local

Add the executed command, don’t forget to add exit at the end

12 /opt/tmux.shexit 0

Increase executable permissions

1 sudo chmod +x /etc/rc.local

note:

If it is to modify an environment variable

Modify the current user:

1 nano ~/.bashrc

Effective for all users:

1 nano ~/etc/profile

Finally, the simplest and rude way to perform tasks on startup is included

Just start a tmux session in /etc/rc.local and execute the commands you want to run in it; simple and rude and effective

Here is a template:

1234567891011121314151617181920 #! /bin/bash# description "Start Tmux"# Sleep for 5 seconds. If you are starting more than one tmux session# "at the same time", then make sure they all sleep for different periods# or you can experience problems/bin/sleep 5# Ensure the environment is availablesource ~/.bashrc# Create a new tmux session named newscrawler../usr/bin/tmux new-session -d -s bitcoin# ...and control the tmux session (initially ensure the environment# is available, then run commands)# /usr/bin/tmux send-keys -t bitcoincash:0 "source ~/.bashrc" C-mtmux new-window -n console -t bitcoin/bin/sleep 3/usr/bin/tmux send-keys -t bitcoin:0 "cd /opt/bitcoin && ./startbitcoind.sh" C-m/bin/sleep 3/usr/bin/tmux send-keys -t bitcoin:1 "cd /opt/bitcoin && ./checkwallet start" C-m

Recommended Posts

How to Run Tmux Service Scripts on Ubuntu Start Up
How to set up Gogs on Ubuntu 14.04
How to build nfs service on ubuntu16.04
How to set up R on Ubuntu 14.04
How to set up Shiny Server on Ubuntu 14.04
How to install R on Ubuntu 18.04 [Quick Start]
How to set up time synchronization on Ubuntu 18.04
How to run the parsing server on Ubuntu 14.04
How to install Git on Ubuntu 18.04 [Quick Start]
How to install Anaconda on Ubuntu 18.04 [Quick Start]
How to set up a DNS server on Ubuntu 18.04
How to start a blog with Hexo on Ubuntu 14.04
How to install Ruby on Ubuntu 20.04
How to install Memcached on Ubuntu 20.04
How to install Java on Ubuntu 20.04
How to install MySQL on Ubuntu 20.04
How to install VirtualBox on Ubuntu 20.04
How to install Elasticsearch on Ubuntu 20.04
How to install Protobuf 3 on Ubuntu
How to install Nginx on Ubuntu 20.04
How to install Apache on Ubuntu 20.04
How to install Git on Ubuntu 20.04
How to install Node.js on Ubuntu 16.04
How to install MySQL on Ubuntu 20.04
How to set up Java Home on Ubuntu and Raspbian
How to install Vagrant on Ubuntu 20.04
How to install Bacula-Web on Ubuntu 14.04
How to install PostgreSQL on Ubuntu 16.04
How to install Git on Ubuntu 20.04
How to set up a Masterless Puppet environment on Ubuntu 14.04
How to install Anaconda3 on Ubuntu 18.04
How to install Memcached on Ubuntu 18.04
How to install Jenkins on Ubuntu 16.04
How to install MemSQL on Ubuntu 14.04
How to set up a firewall with UFW on Ubuntu 14.04
How to install Go on Ubuntu 20.04
How to install MongoDB on Ubuntu 16.04
How to install Mailpile on Ubuntu 14.04
How to install PrestaShop on Ubuntu 16.04
How to upgrade to PHP 7 on Ubuntu 14.04
How to install Skype on Ubuntu 20.04
How to install Jenkins on Ubuntu 20.04
How to install Python 3.8 on Ubuntu 18.04
How to install KVM on Ubuntu 18.04
How to set up vsftpd for anonymous downloads on Ubuntu 16.04
How to install KVM on Ubuntu 20.04
How to install opencv3.0.0 on ubuntu14.04
How to install Anaconda on Ubuntu 20.04
How to install Prometheus on Ubuntu 16.04
How to install Jenkins on Ubuntu 18.04
How to deploy Django on Ubuntu 14.04
How to install Apache on Ubuntu 20.04
How to install R on Ubuntu 20.04
How to set up a production Elasticsearch cluster on Ubuntu 14.04
How to set up an Apache virtual host on Ubuntu 16.04
How to install Moodle on Ubuntu 16.04
How to install Solr 5.2.1 on Ubuntu 14.04
How to set up an Apache virtual host on Ubuntu 20.04
How to install Teamviewer on Ubuntu 16.04
How to secure Nginx on Ubuntu 14.04
How to install MariaDB on Ubuntu 20.04