I want to create a custom command on linux (ubantu) which I need to execute regularly.

steps are:

  1. create a shell-script
  2. place the shell script in /usr/bin/ dir
  3. name of shell-script file is custom command

e.g

I want kill node processes running by just typing “killnode”

#!/bin/bash

#fileName /usr/bin/killnode

#echo "the folder is `pwd`"
#echo "The folder which contains files are `ls`"

nodeKaPids=`pidof node`
echo "Pids of node are: ${nodeKaPids}"
`kill -9 ${nodeKaPids}`
echo 'nodes are killed'

Leave a Reply

Your email address will not be published. Required fields are marked *