Raspberry pi course tutorial - Services

A service is one or more applications that run in the background and do not require the console to run.  These services perform background task such as cleaning up temporary files, initialising the system, waiting for internet connection or running databases.  Some services will listen for connection from clients such as the Apache web server which will send out a web page when it receives a request connection.

When a the Raspberry Pi boots up, the operating system starts these services and does this by the use of a program called init.  The init program uses a number of scripts to start and stop processes.

Each distribution has run levels and each run level contains a number of services each designated to perform certain tasks.  For example you only require a basic installation without a desktop then there is no reason to load the run level with a desktop.  A run level of 0 is used to halt the system and it is this run level that is called into action when you shut down the system.  Run level 1 is used in single user mode only and a run level of 6 is used for rebooting.

[Not all run systems are the same for each distribution so be sure to read the documentation]

Services will sometimes need to be started, restarted,  etc.  Most services will allow you to interact with it from a console by calling upon scripts to do the work.  Links to these scripts can be found in the /etc/init.d directory and the syntax looks like this.

/etc/init.d/the-command OPTION.

Commands that can be used are start, stop, reload, restart and force-reload.

[A service is commonly known as a daemon]

Anacron is a service that runs in the background and executes commands throughout the  day, week, month or year depending on how it has been configured.  Stop this service by entering the following.

$ sudo /etc/init.d/anacron stop

Stopping anac(h)ronistic cron: anacron.

Now start anacron again by entering.

$ sudo /etc/init.d/anacron start

Starting anac(h)ronistic cron: anacron.

Anacron should now continue as a daemon in the background.

 

Raspberry Pi Users & groups

Next Raspberry Pi Users & Groups – Week 5  Day 5.0 >>