Exploring cron

Exploring Cron – II

In our previous blog we have overview of how to create a cron expression.

This blog will walk you through some solid example, which will help you to get detailed undertstanding of crontab (Chronos tab or chornological table)

1. How do I see the current cron tab entry?

A) From command prompt we need to fire the command

sudo crontab -l

2. How do I edit the entry of cron tab?

A) -e switch of the cronttab will help you to edit the entries (default vi editor)

sudo crontab -e

3. How do I execute every minute?

A) * * * * * /path/to/your/script.sh

4. How do I execute every saturday 2 AM?

A) 0 2 * * 6 /path/to/your/script.sh (Here 6 represent Sarturday and 2 represent the 2nd Hour i.e 2 AM

5. How do I execute a script every 20 minutes?

A) 0,20,40 * * * * /path/to/your/script.sh 

Keywords in Crontab entries.

@reboot     this will invoke to execute your script when the system startup
@yearly     this will run once in a year
@annually   this will invoke the script once in a year
@monthly    this will invoke the script once in a month
@weekly     this will invoke the script once in a week
@daily      this will invoke the script once in a day
@midnight   this will invoke the script daily
@hourly     this will invoke the script every hour

Service in Linux

Service in Linux

The service are set of programs that run as background process, so it is ready to use anytime by the users. The service gets started when the machine is rebooted automatically.

How to create a Service?
The creation of service is useful when the application is used everytime. This helps the user to save time by frequently starting and stoping the program/application.

We can create a service by writing our own shell scipt and moving the copy of the file in init folder such as /etc/init.d.

What is special about service script in linux?
The shell script that is used for service creation are special script. They have to follow certain coding pattern. The script should have certain function such as start, stop, status, restart etc.

The service script has a header known as LSBscript. A sample of it may look like this

# Provides: scriptname
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start daemon at boot time
# Description: Enable service provided by daemon.

Provides: here we need to write the name of the service.
Required-Start: space separated list of program/application that this service required to start itself
Required-Stop: space separated list of program/application that should be stopped when this service is stopped
Default-Start/Default-Stop: The number tells the linux system the runlevels of the program/application the range is generally in between 0 to 6
Short-Description: Simple descript that will be displayed when the service is contacted
Process id: This is a unique number that helps to identify the process. Whenever we start any application in the linux it associate that process with an unique id.

Mechanism that may be followed when writing a service script.
1. The script should be initiated by the root/super user.
2. The script should not contains any harmful script
3. The Process id may be captured by the user so that the status can be determined.
4. The log file can be associated with the program running in the background that may be hlep to debug when application fails

update-rc.d command:
This command helps the user to add/remove services.
To add a script the following command may be run.
update-rc.d -f service_name defaults
To remove the service the following command may be run
update-rc.d service_name remove

When service is added, the application/program can be started/stopped using service command.
eg. sudo service ApplicationName start
eg. sudo service ApplicationName stop



vsftpd is lightweight, highly stable, secure, and fast FTP server for Linux environment. vsftpd also supports virtual ip, virtual users, bandwidth throttling, IPv6, encryption etc..

This article provides step-by-step instructions to set up FTP Server on your LINUX machine:


Install vsftpd:

sudo apt-get install vsftpd


Configure your vsfpd configuration file. You can find it on location /etc/vsftpd.conf

Uncomment following options in vsftpd.conf file:


anonymous_enable=YES (To Enable Anonymous user login)



Restart vsftpd service:

sudo service vsftpd restart



Now, you can access you FTP server on port 21.

Test your set up:

ftp localhost

For more configuration details, follow the link:


Here, you can find more description of vsftpd configuration parameters.

Change Default Port VSFTPD

VSFTPD default port is 21. If you want to change default port to any other port, follow the steps:

Add following options to vsftpd.conf:






Allow outbound rule in firewall for these passive ports. You can save these using iptables:

iptables -I INPUT -p tcp –destination-port 10090:10100 -j ACCEPT


Restart your vsftpd service after changing ports:

sudo service vsftpd restart





Add the following options in vsftpd.conf file to enable FTPS:



No need to create a certificate if openssl package is installed!

Restart your vsftpd service:

sudo service vsftpd restart



Both FTP and FTPS using vsftpd

If you want to start your FTP and FTPS server simultaneously, you can achieve it by starting 2 services of vsfpd.

1)      Copy /etc/vsftpd.conf to /etc/vsftpd-ssl.conf

2)      Edit and configure /etc/vsfpd-ssl.conf for FTPS server.

3)      Save it.

4)      First start vsftpd service (FTP) sudo service vsftpd start

5)      Now, start vsftpd service for FTPS:   sudo vsftpd /etc/vsftpd-ssl.conf


— Sharad Sinha