How would you automate scripts using Google Cloud Function and Cloud Scheduler?

258 views
Skip to first unread message

Patrick Haley

unread,
Sep 4, 2022, 11:00:59 AM9/4/22
to GAM for Google Workspace
Hey everyone, I know you can use a CRON job to automate GAM commands, but I'm interested in running this through cloud function and cloud scheduler. I've found to simple video tutorials, but I'm not sure if it's possible wit GAM. From my limited understanding it seems like to I need to initiate the command via a python script in cloud function, which can be invoked via cloud schedule. Does this seem like the right approach and if so, how to I process a GAM command via python?

Maj Marshall Giguere

unread,
Sep 4, 2022, 12:47:30 PM9/4/22
to google-ap...@googlegroups.com
I have many management functions that are run as GAM commands via CRON.  My technique is to create a file with a collection of GAM commands and then invoke GAM in batch mode.  I use GAMADV-XTD3, my system runs on a cloud instance with jobs that run on daily, weekly, monthly schedules.  Example:  create a bunch of new users
file: newusers.job
gam create user us...@somedomain.com ...
gam create user us...@somedomain.com ...
gam create user us...@somedomain.com ...
...

Invoke gam to create the users:
gam batch newusers.job

So, to answer your question the answer is yes, and no you don't need a Python script to kick things off.

Maj Marshall E Giguere

NH Wing Director of IT

Civil Air Patrol, U.S. Air Force Auxiliary

GoCivilAirPatrol.com

nhwg.cap.gov

Volunteers serving America's communities, saving lives, and shaping futures.



On Sun, Sep 4, 2022 at 9:01 AM 'Patrick Haley' via GAM for Google Workspace <google-ap...@googlegroups.com> wrote:
Hey everyone, I know you can use a CRON job to automate GAM commands, but I'm interested in running this through cloud function and cloud scheduler. I've found to simple video tutorials, but I'm not sure if it's possible wit GAM. From my limited understanding it seems like to I need to initiate the command via a python script in cloud function, which can be invoked via cloud schedule. Does this seem like the right approach and if so, how to I process a GAM command via python?

--
You received this message because you are subscribed to the Google Groups "GAM for Google Workspace" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-man...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-manager/e7f2e0ee-96c0-4319-9460-dad94171bf62n%40googlegroups.com.

Patrick Haley

unread,
Sep 4, 2022, 4:12:02 PM9/4/22
to GAM for Google Workspace
Thanks Marsh, the more I look into it it seems like CRON is the way to go. I'm a newbie to CRON so can you provide an example of what one of your jobs looks like?

Patrick Haley

unread,
Sep 4, 2022, 4:41:58 PM9/4/22
to GAM for Google Workspace
Actually managed to figure this out. For anyone who stumbles on this in the future read on for the solution...

  1. I created a simple Google Cloud  E2 micro instance so I could keep the server running 24/7.
  2. Installed GAM per the standard Linux instructions. 
  3. Read this article on creating executables https://sites.google.com/jis.edu.bn/gam-commands/systems/compute-engine/cron#h.euezabehbw0p
  4. Created a directory called "/GAMScripts" and saved the .sh file in there. 
  5. Created a CRON job to test sending an email to myself every minute: "* * * * * cd /home/patrick/bin/GAMScripts/ && ./test.sh" 

Jason Raynor [Staff]

unread,
Nov 10, 2022, 12:13:05 PM11/10/22
to GAM for Google Workspace
Hey Patric,


"I created a simple Google Cloud  E2 micro instance so I could keep the server running 24/7."

What are the costs like for that Google Cloud micro instance?

Patrick Haley

unread,
Nov 10, 2022, 12:23:51 PM11/10/22
to google-ap...@googlegroups.com
I actually just saw the receipt for it a couple of days ago and it was like $3. 

This e-mail and any attachments are the property of the Halton District School Board and are intended only for the use of the addressee(s) and may contain information that is privileged and/or confidential and/or protected under the Education Act, the Municipal Freedom of Information and Protection of Privacy Act and/or the Personal Health Information Protection Act. Unauthorized review, distribution, copying or disclosure is strictly prohibited. If you are not the intended recipient please notify the sender, delete this message and do not print, copy, distribute or disclose it further.

--
You received this message because you are subscribed to a topic in the Google Groups "GAM for Google Workspace" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/google-apps-manager/1yUC0Gh-tAI/unsubscribe.
To unsubscribe from this group and all its topics, send an email to google-apps-man...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-manager/13295c9b-4847-4176-a87f-11c232650033n%40googlegroups.com.


--
Patrick Haley

Head of Global IT & Systems


Franchisor Team

1114 South Saint Mary's St, #110, San Antonio TX, 78210

C: +1 210 478 2081

This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. The content and opinions contained in this email are not able to be copied or sent to any other recipient without the author’s permission. If you have received this email in error please contact the sender.
Reply all
Reply to author
Forward
0 new messages