How to restart Mac Mail.app every night?

I want to restart my Mac Mail.app software every night at 6am (or any time I choose).

What is the best way to do this?

I DO NOT want to reboot my whole Mac every night, only the Mail.app.

TIA.

UPDATE 7th October 2021

I have found a less complicated way than the suggestions below using the Automator app.

See: https://allthings.how/how-to-automatically-launch-and-close-an-app-on-mac-at-scheduled-times/

Thanks everyone for their help.


Solution 1:

A cron job, something like

0 6 * * * killall Mail && open -a "Mail.app"

You can run as complicated a script as you want like the following

0 6 * * * sh path_to_the_script.sh

Add it to cron with crontab file_above.txt

See man crontab for more info.

https://crontab.guru/#0_6_*_*_*