Michael Dudli

Michael Dudli

Cloud Specialist with more than 10 years experience in the Hosting Business. Website URL: http://www.cloudserver24.com

How to schedule Crontabs

  • Published in Basics

 

Crontab is used to schedule, load or remove scripts. You can schedule your scripts depending upon your needs. Syntax of scheduling a script differs upon time. Some basic commands of crontab are

# crontab -l (List crontabs)

# crontab -r (Removes the crontab file)

# crontab -e (Edit the contab file)

You can use crontab -e to add and remove or comment out the scripts, basic syntax for crontabs will be like the following

* * * * * /tmp/michael.sh

The "*" sign holds a very important value as it every * has some value and you can schedule your crons depending upon the value of *

*               *                       *                          *                     *

min           hr              day of month             month           day of week

So these five values can be set by putting your desired values

Now we will see some examples

Lets suppose we want to execute a script on the first date of every month at 00:45

45 * 1 * *  /tmp/michael.sh

If we want to execute a script from Monday to Friday and from 9AM to 4PM it will be written as

00 09-16 * * 1-5 /tmp/michael.sh

How to Monitor Linux with Basic Commands

 

Monitoring resources is very important as sometimes troubleshooting the issues needs commands whenever the issue is occurring. In this post we will discuss top 5 commands for Linux that everyone should use for monitoring their Linux servers

1) Top:

This is most important command line tool for Linux as it shows ongoing activity of your server in real time and lets you which process is taking how much resources. 

A colored version of “top” is known as “htop” that needs to manually installed 

 

 

 

2) Vmstat

If you want in depth information of your memory, processes and paging then this command is your friend

#vmstat 3

procs -----------memory---------- ---swap-- -----io---- -system-- ----cpu----

 r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa

 0  0      0 109320  66648 1762356    0    0     0    24    6   27  0  0 100  0

 0  0      0 109312  66648 1762452    0    0     0     0  178  359  0  0 100  0

 0  0      0 109312  66656 1762444    0    0     0    15  175  367  0  0 99  1

 0  0      0 109312  66656 1762456    0    0     0     0  173  359  0  0 100  0

 0  0      0 109312  66656 1762456    0    0     0     0  176  355  0  0 100  0

 0  0      0 109312  66664 1762456    0    0     0     5  177  356  0  0 99  1

 0  0      0 109312  66664 1762460    0    0     0     0  172  363  0  0 100  0

 0  0      0 109312  66672 1762460    0    0     0     4  173  361  0  0

 

 

3) W:

As a server admin you need to monitor the persons who are logged in but how would you know if someone else is logged in also and what is he doing

The basic syntax is 

#w username

An example is as follows

w

 08:41:52 up 8 days, 21:11,  1 user,  load average: 0.00, 0.01, 0.05

USER     TTY      FROM             LOGIN@   IDLE   JCPU   PCPU WHAT

root     pts/0    192.168.21.116   07:00    0.00s  0.08s  0.00s w

        4)uptime:

To check that for how much time a server is running a simple command named “uptime” is used. It comes with various options and following is an example of it

# uptime

08:43:39 up 8 days, 21:13,  1 user,  load average: 0.00, 0.01, 0.05

        5)free

This is a command which will help you to check how much RAM and SWAP consumption you are doing while using your server and it can be helpful in disastrous times

# free –m

total       used       free     shared    buffers     cached

Mem:          2024       1897        126          0         66       1698

-/+ buffers/cache:        132       1891

Swap:         3136          0       3136

 

How to install VNC on Linux

 

Normally expert level Linux users use CLI or SSH for servers but there happens sometimes that we have lost SSH access and in result we cannot access the server, here comes the importance of tool named as VNC which is GUI for you Linux server 

To install VNC on your Linux server you have to first install gnome by following command

#yum groupinstall "GNOME Desktop"

Then install VNC

#yum install tigervnc-server

To access VNC you have to add a user for VNC let’s say we add vnctest as a user by following command

#useradd vnctest

After giving the password for your user then you have to add this user to your VNC config file

#vi /etc/sysconfig/vncservers

[...]

VNCSERVERS="1:vnctest"

VNCSERVERARGS[1]="-geometry 1024x768"

Now restart the VNC service by 

#/etc/init.d/vncserver restart

Now you can download VNC viewer from google and add the IP:Port for your server with username and password 

Note: Port for VNC server is normally 5901 and for the next user it will be incremented 

How to install & Mount files using SSHFS

  • Published in Basics

 

SSHFS is an application that allows you to mount your folder to a remote server. Its very easy to install and configure with simple one line command

To install SSHFS use the following command

#yum install sshfs

Let’s do this on two servers by mounting a folder of one server with another server but let me make a folder first

#mkdir /tmp/mnt

A folder in tmp with name mnt has been created, now I will mount this folder remotely to another server 

Let’s say that other end IP is 192,.168.21.2

#sshfs  This email address is being protected from spambots. You need JavaScript enabled to view it..2:/ /tmp/mnt

Now all of your files which are present in mnt folder will be present in the second server 

If you ever feel to unmounts your folder just use the following command

#unmount /tmp/mnt

 

Subscribe to this RSS feed