Reboot Server Daily

Hello Team,

I’ve a simple question…
how to add a restart cron job with frequency of daily at specific time.
I tried using HestiaCP but it doesn’t work

This is not a way to ask question on help forums. First mention clearly what you tried, how you tried to setup cron and what OS Version are you on

Sorry for incomplete information.

OS : Ubuntu 20.04
HestiaCP Ver. - 1.2.0

Issue: Need to Create a cron job to restart server daily at 3:00.

Explain

i just created a cron job with sudo permission and give timing as per the requirement but later it shows no response.

command is : sudo /sbin/shutdown -r now

Under which user you put this cron ?
You need sudo rights to reboot/poweroff so pls dbl check it is under “admin”

use the modern systemd command
sudo systemctl reboot

Finally after setting up Cron, verify it through SSH command line by listing all cron schedules setup for ‘admin’. It should show up in the end of list
crontab -l -u admin

Remove now it is not needed for restart

admin user is only limited to

sudo is limited to hestia scripts

admin ALL=NOPASSWD:/usr/local/vesta/bin/*
admin ALL=NOPASSWD:/usr/local/hestia/bin/*

You will need to modify the root crontab instead…

yep…

:hot_face: What? This isn’t Windoze! There should be absolutely no need to reboot a server on a daily basis. There are *nix boxes that have stayed up for decades - not me, as I don’t have Kernel Care and need to reboot to activate an updated kernel.
You should identify which service(s) need(s) a restart and do that instead. :face_with_head_bandage:

2 Likes

Why do you want this?

due to issue with database, but later I found that even this is not the solution…

edit: doing this damages mariadb so badly that i have to reinstall my server from scratch… not a good idea at all.

1 Like

Maybe just fix the database then no need for reboots? add more ram to vps/server or tune mariadb to suit your server specs :slight_smile:

make a new cronjob with code below:

sudo /usr/local/hestia/bin/v-restart-system yes 1

Change last parameter (1) to the second you want to sleep before restart.

No need to bump a 3 year old topic