Shell Scripts

Create a server service

Create a server service thats run on the server startup

Bash script

Create a bash script (call it "myservice" or whatever) with 766 permisions, on server folder "/etc/init.d"


case "$1" in
  echo -n "[....] Starting service: myservice"
  # ...
  sleep 1 && echo -e "\e[0K\r[ \e[32mok\e[39m ]"
  echo -n "[....] Stopping service: myservice"
  # ...
  sleep 1 && echo -e "\e[0K\r[ \e[32mok\e[39m ]"
  echo -n "[....] Restarting service: myservice"
  # ...
  sleep 1 && echo -e "\e[0K\r[ \e[32mok\e[39m ]"
echo "Usage: /etc/init.d/myservice {start|stop|restart}"
exit 1
exit 0


Start or Stop the service from the shell

service myservice start
service myservice stop
service myservice restart

Compress files with gzip

Compress the Javascript and CSS files on the server for optimize web speed. It will be compressed into new files with a .gz extension. [ read ]

List files with options

List files on the current path on vertical display with invislible files, file permisions, owner and size in human readable format. [ read ]