First, find out your directory's path by calling:
pwd
Let's say, this is
/home/admin
Now create a maintenance script. This will call our two previous scripts: First we run our backup, and then we run the updates. We will want the updates to go through even if the previous script failed.
touch maintenance.sh
chmod +x maintenance.sh
Then edit the file and paste in:
#!/bin/bash
pushd /home/admin
./pgdump.sh || true
./system-update.sh || true
popd
Replace
/home/admin with the output you got from the
pwd command above.
Now we want to run the maintenance script every night, when not much is happening on the server. Type:
crontab -e
And add the following line:
30 2 * * * /home/admin/maintenance.sh
Again, replace
/home/admin with the output you got from the
pwd command above.
This will run the backup, updates & reboot at 2:30 am every day. If you want to schedule this differently, use
crontab.cronhub.io to help you with the
cron expression.