Update your Bookmarks to https://sites.google.com/view/gam--commands/home
https://www.digitalocean.com/community/tutorials/how-to-use-cron-to-automate-tasks-ubuntu-1804
Open a terminal window and enter each command individually, press enter after each.
sudo apt update
sudo apt install cron
sudo systemctl enable cron
The time zone of your VM needs to be changed to ensure that the cron jobs are exectuted at the correct local time.
From this page, go root user
sudo -s
and use
dpkg-reconfigure tzdata
This will bring up a GUI which will guide you to change your timezone information
Afterwards, confirm the date/time by typing date. I am not sure if needed but the Compute Engine Region & Zone was changed to one in the same local time zone and the VM was restarted. This is from the Settings section for the VM in Compute Engine.
Create a file to contain the GAM command. Nano (https://www.nano-editor.org/) is a builtin text editor, so the terminal screen will change.
sudo nano <File Name>.sh
Then add
#! /bin/bash
/path/to/GAM/folder/<Your GAM Command Here>
Example
#! /bin/bash
/home/user_name/bin/gamadv-xtd3/gam crosqueries "status:active" print cros todrive
The commands in nano to save the file are
CTRL + x (to exit the file) > Y (to confirm saving the changes) > Enter (to confirm file name)
sudo chmod +x <File Name>.sh
Make sure the script file is working.
./<File Name>.sh
Edit the file that controls all the cron jobs
crontab -e
For example to run nightly at 1am. The /path/to/script/ is where the .sh file is stored, not the GAM location.
0 1 * * * /path/to/script/<File Name>.sh
Or, to run on the 4th day of every month. This example will run the script at 3.45am on the 4th day of every month.
45 3 4 * * /path/to/script/<File Name>.sh
Example
0 1 * * * * /home/user_name/scripts/update.sh
This website, https://crontab.guru/, has useful examples and an expression checker for creating the cron timing.
crontab -l > /path/to/backup/crontab.bak
https://futurestud.io/tutorials/ubuntu-debian-how-to-test-a-cron-job
https://www.digitalocean.com/community/tutorials/how-to-use-cron-to-automate-tasks-ubuntu-1804
https://www.geeksforgeeks.org/crontab-in-linux-with-examples/
https://tecadmin.net/crontab-in-linux-with-20-examples-of-cron-schedule/
https://cronitor.io/cron-reference
Time Zone - Compute Engine
linux > date to show day/time