Linux restarts the server regularly

Time:2020-11-16

Requirement description

The system configuration is low, and the application program has been executing timing tasks. After the program runs for a period of time, it is found that the interface request will become very slow, and the server needs to be restarted regularly in the morning every day

Script implementation

1. Input crontab – E in Linux terminal to add timing task script command

[[email protected] ~]#  crontab -e

2. Add at the end of the document

0 0 * * * /sbin/reboot;

3. Restart the service to make the scheduled task take effect

systemctl restart crond

4. Configure the timing task to start automatically

Check whether the service starts automatically

systemctl list-unit-files|grep crond.service

If there is no power on self start, set the power on auto start

systemctl enable crond