Question

In: Computer Science

Need to process these steps in UNIX. To encourage users to get a good night's sleep,...

Need to process these steps in UNIX.

To encourage users to get a good night's sleep, it has been decided that the web server will be unavailable from 23:30 each night until 07:00 the next morning.

Create a cron file named /etc/cron.d/web that stops httpd each evening at 23:30 and restarts it the next morning at 07:00.

Solutions

Expert Solution

Run the following command to create the file:

touch /etc/cron.d/web

Code to be written in this file:

#define the shell which will be used to run the commands
SHELL=/bin/bash
#defines the path of shell
PATH=/sbin:/bin:/usr/sbin:/usr/bin
#if you want to send the mail to user, set this property
MAILTO=""
#cronjob to stop the web server each night at 23:30
30 23 * * * root systemctl stop httpd
#cronjob to start the web server each morning at 07:00
00 07 * * * root systemctl start httpd

The first 5 parameters of the cron job are used to define the time when the cronjob would be run.

1st is for the minutes. 2nd is for the hours. 3rd is for the day of the month. 4th is for the month. 5th is for the day of the week. These must be followed by the command which needs to be run.

As we want our cronjob to run each day, we set the last three parameters as * which means for all the values of that parameter. For the first two, we define the minutes and hours.

Also, to stop or start the httpd service we require administrator access so we specify the keyword root before writing those commands to provide root access while running the job.


Related Solutions

There are four steps that need to be taken to process a business's financial transactions.
There are four steps that need to be taken to process a business's financial transactions. The first is to identify all of the financial transactions that a company has made within a specific time frame, usually monthly. The second step is to analyze each transaction individually. The next step is record these transactions onto a financial journal by date. The final step is to transfer these figures onto a company ledger.. It is very important that you record all of...
There are several steps need to be considered to fulfill the structural design process. Describe the...
There are several steps need to be considered to fulfill the structural design process. Describe the design process which involves building form and structural arrangement.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT