Jenkins ( is used for automated continuous integration and can be used for server management too.

Install Jenkins and Nginx on CentOS 7:

Make Jenkins a sudoer:

#open /etc/sudoers to edit
sudo mcedit /etc/sudoers

#let jenkins run any command by adding this line
jenkins ALL=(ALL) ALL

#let jenkins run 'sudo' without asking for password

Let Jenkins run bash script on remote Linux machine through SSH:

1. Generate an RSA key pair

2. Add the public key to the remote machine (to home directory of ‘someuser‘)

3. Copy the private key to directory ‘/var/lib/jenkins/.ssh/‘ with name ‘id_rsa

4. Add new build item in Jenkins with the following shell command in ‘Build’ section to test (note that the ‘someuser‘ is to match the one in step 2 above):

#add -v for verbose info
ssh -oStrictHostKeyChecking=no \ <<SSHBLOCK

Git command with GitHub using personal access token or password:

#example git pull, PAT=personal access token
git pull

Run programme, .sh script, .js script as daemons (this is necessary as Jenkins will terminate all processed called in build process):

1. Run a programme as daemon

#install on centos|redhat
sudo yum install daemonize

daemonize -E BUILD_ID=dontKillMe /path/to/programme

2. Run an .sh script as daemon

setsid >/dev/null 2>&1 </dev/null &

3. Run a .js script as daemon (especially in NodeJS project, PM2 can be used instead of the ‘forever’ module:

npm install forever

BUILD_ID=dontKillMe forever start somescript.js

#stop a daemon started by 'forever'
forever stop somescript.js

#get a log of daemon started by 'forever'
forever logs somescript.js

4. Find and kill a process

sudo pkill -f "something in command-line"