I'm running a unifi accesspoint with OpenWrt. I want to create a cronjob the reboots the device on 1st of every month.
I tried:
$ crontab -l
$ 50 16 23 * * /sbin/reboot
The accesspoint rebooted properly, BUT after that the crontab job is lost.
Now in your docs I read about watchcat. Is this the better solution for periodic reboots?
If yes, how can I configure it properly for a monthly reboot after executing the opkg install watchcat from docs?
@hnyman has given you good information about how to do this.
I'd like to ask why you're interested implementing a reboot script. OpenWrt is generally very stable and should not need to be rebooted very frequently at all (typically only needing reboots when doing a sysupgrade, installing certain packages, or making major configuration changes). If you are running into specific problems, you're better off trying to solve those problems than simply rebooting (which just masks the issue). If it is 'just because' you'd like to reboot every month, consider that it isn't usually necessary and often creates more headaches than it is worth, especially if you mess up and get a reboot-loop going).
Unfortunately all files under /etc/crontabs/ or /etc/persistent/ are gone after a reboot. Do you know why? Is there any other persistent path? Or is there anything special I have to take into account creating the files?
No wonder your settings are gone, you are running on tmpfs.
Any reason why you are still using 17.01.6 instead of 19.07.2?
Which OpenWrt image exactly have you flashed (please provide link)?
I'm just running the default openwrt that was shipped with my access point "unifi ap ac lite".
I don't know if I could simply upgrade openwrt within? Especially as then my management interface from ubiquiti might not work anymore?
Sure,
but if you use something Unifi OEM specific in their OEM firmware, then you better ask help at their forums, as your things have nothing to do with the proper OpenWrt
This is not a standard LEDE/OpenWrt release -- it is highly customized by Ubiquiti. Just as a reference point, the Unifi AP's are access points only based on their firmware -- they are not setup as routers (a default OpenWrt/LEDE installation sets up the device as a router). Assuming that you are indeed using the Unifi Controller environment, I would highly recommend against messing with the base OS because it may produce unpredictable/unstable results.
Yup... the Unifi Contoller only works with the Unifi firmware. If you install an official release of OpenWrt, you will need to manage the device directly via ssh or http/s (LuCI). OpenWrt is great, but you should evaluate the pros/cons of switching to the official OpenWrt releases -- I personally love the Unifi environment and have specifically opted to stay within this walled garden for my WiFi (I use OpenWrt on other devices).
Meanwhile, I would start with making sure that you are fully up to date with the Unifi Controller and firmware(stable versions 5.12.35 and 4.0.80 respectively as of March 18, 2020).
Then, ask yourself the question I had asked earlier about why you want to do this (you never did answer this). Are you experiencing a specific issue? Most of the time, the Unifi firmware is solid... I have 2x AC-PRO devices that have uptime of 65 days (the last time they were rebooted was for a firmware update). You really shouldn't need to restart these things all that often, if ever, aside from certain major configuration changes and/or firmware updates (this is true for both the Unifi specific firmware and OpenWrt), so a reboot script should not be necessary under normal circumstances.
EDIT: I would not recommend changing from Unifi to official OpenWrt purely for the ability to schedule reboots, but don't let that stop you if you see other benefits. That said, if you are indeed experiencing issues that require reboots and plan to stick with Unifi, as @hnyman said, head over to the UI community forums and ask how to resolve them there.