This will help you set up a cronjob that will trigger a script that deletes and archives OT Node logs on the 1st of every month. The archived files are stored in ~/NodeArchive. You will receive a Push notification whenever ever the script completes or fails. If the script does fail, the notification will include log statements to identify the issue.
Install the 'Notify My Device' app from the app store and install it onto your mobile device.
Navigate to https://www.notifymydevice.com/ and create an account. Go to 'My applications' and create an application. Copy the API key and save it for later.
Note: Ensure you have write permissions for your log file that can found when you run docker inspect -f '{{.LogPath}}' otnode
On your node:
Install npm, nodejs
- sudo apt install npm
- sudo apt install nodejs
Edit your environment variable inside of your directory and add your container name found when you run the command mentioned in the note.
- Sudo nano .env
- Paste and edit the variable below
CONTAINER=mycontainer
APIKEY=myAPIkey
NODENAME="my nodes name"
Add a Cron job to the bottom of your crontab to trigger the script. Test running the command before adding it to your crontab.
- Sudo nano /etc/crontab
- Edit and Paste the command below to the end of your crontab
0 0 1 * * root cd ~/path/to/my/script/ && node process.js