Scheduling GAM to run commands on a schedule?

2,610 views
Skip to first unread message

Gretchen Nobles

unread,
Jan 7, 2011, 1:01:33 PM1/7/11
to google-ap...@googlegroups.com
Can anyone direct me to instructions for running GAM commands on a schedule?  I'd like set GAM to run commands to turn off webclips, pop, IMAP and email Forwarding automatically everyday.

Thanks!

Gerard Duerrmeyer

unread,
Jan 7, 2011, 2:34:29 PM1/7/11
to google-ap...@googlegroups.com
I would recommend setting it up as a cronjob.
If you are not on a *nix based system, there are windows ports of
various cron daemons.
I would recommend setting it up on one of your, ideally non-windows
based, servers.
Most *nix based systems you can edit your entries by simply:
[prompt] crontab -e

Some reading on crontab: (I do not endorse these links, merely found
them amongst some google results and they "appeared" to be useful at
first glance)
- http://www.crontabrocks.org/
- http://adminschoice.com/crontab-quick-reference

To make sure that it is all working (permissions, file paths etc...),
you might schedule a sample item to perform something on a test
account that you can visually verify through the webUI.

Good luck!

Cheers,

GD

> --
> You received this message because you are subscribed to the "Google Apps
> Manager" group.
> To post to this group, send email to
> google-ap...@googlegroups.com
> To unsubscribe from this group, send email to
> google-apps-man...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/google-apps-manager
>

Gretchen Nobles

unread,
Jan 7, 2011, 2:54:07 PM1/7/11
to google-ap...@googlegroups.com
Wow.... that sounds WAY more complicated than what I can handle at the moment!  Any other ideas?

Jay Lee

unread,
Jan 7, 2011, 2:55:16 PM1/7/11
to google-ap...@googlegroups.com
You can use Scheduled tasks in Windows:


Jay

On Fri, Jan 7, 2011 at 2:54 PM, Gretchen Nobles <gno...@gmail.com> wrote:
Wow.... that sounds WAY more complicated than what I can handle at the moment!  Any other ideas?

--

Gretchen Nobles

unread,
Jan 7, 2011, 3:25:24 PM1/7/11
to google-ap...@googlegroups.com
I looked at that... but what exactly would I schedule?  GAM.exe and then enter my command?  Or would I have to write some sort of batch file?

Sorry... I'm really new at all this!

Jay Lee

unread,
Jan 7, 2011, 3:28:56 PM1/7/11
to google-ap...@googlegroups.com
I would recommend writing a batch file that calls all of the gam commands you want to run. Then once you've verified the batch file is working on it's own, schedule that batch file to run. I suggest scheduling it to run on an hourly basis at first and testing that it's working by changing a few settings for some users and seeing if it gets reset in an hour.

Note that you'll also want to make use of auth.txt since the token.txt that GAM creates when you login will expire every 24 hours and will need to be recreated. If auth.txt doesn't exist with authentication info then GAM will do nothing more than prompt for login. See:


for more info on auth.txt

Jay

On Fri, Jan 7, 2011 at 3:25 PM, Gretchen Nobles <gno...@gmail.com> wrote:
I looked at that... but what exactly would I schedule?  GAM.exe and then enter my command?  Or would I have to write some sort of batch file?

Sorry... I'm really new at all this!

--

Gretchen Nobles

unread,
Jan 7, 2011, 3:33:06 PM1/7/11
to google-ap...@googlegroups.com
Thanks!  I did do the auth.txt already.

So... anyone want to give me a simple example .bat file?? Or point me to a batch file for dummies support group???  ;-)

Also - am I able to do multiple commands in one batch file or would I have to create a new one for each command?  (One to turn off webclips... another to turn off pop... etc)

Jay Lee

unread,
Jan 7, 2011, 3:40:38 PM1/7/11
to google-ap...@googlegroups.com
Try just the following 4 lines. Batch files aren't really anything more than a bunch of commands in a file:

gam.exe all users forward off noconfirm
gam.exe all users pop off for allmail action keep noconfirm
gam.exe all users imap off noconfirm
gam.exe all users webclips off

Jay

--

Gretchen Nobles

unread,
Jan 7, 2011, 3:52:13 PM1/7/11
to google-ap...@googlegroups.com
Awesome!  It's not as hard as I thought!!!!  I have learned SO MUCH this week!!!!

Any idea if there is a command is to keep the cmd window open?

Jay Lee

unread,
Jan 7, 2011, 3:54:14 PM1/7/11
to google-ap...@googlegroups.com
What do you mean keep the command window open? What are you trying to do?

Jay
--
Jay Lee | Senior Network / System Administrator
Philadelphia Biblical University
200 Manor Ave | Langhorne, PA 19047-2990



On Fri, Jan 7, 2011 at 3:52 PM, Gretchen Nobles <gno...@gmail.com> wrote:
Awesome!  It's not as hard as I thought!!!!  I have learned SO MUCH this week!!!!

Any idea if there is a command is to keep the cmd window open?

--

Gretchen Nobles

unread,
Jan 7, 2011, 3:55:43 PM1/7/11
to google-ap...@googlegroups.com
Google search says to enter 

pause

That seems to work pretty well for me!!!

Thanks so much guys!  I'll play around with it and see how it goes!!!

Steve Hall

unread,
Jan 7, 2011, 4:05:09 PM1/7/11
to google-ap...@googlegroups.com
If you want to create batch scripts that pause but will also work
unattended (i.e. not pause forever in the background when they're run
via a schedule), use the "timeout" command instead of "pause". The
"timeout.exe" utility comes with some newer versions of Windows, or you
can get it from here as part of the Windows 2000 Resource Kit:
http://www.petri.co.il/download_free_reskit_tools.htm

Steve

Gretchen Nobles

unread,
Jan 7, 2011, 4:11:38 PM1/7/11
to google-ap...@googlegroups.com
Thanks... I just meant that I was looking for the cmd window to stay open so that in the morning I could see that it ran.  Is that dumb?

Steve Hall

unread,
Jan 7, 2011, 4:16:28 PM1/7/11
to google-ap...@googlegroups.com
No, not dumb at all :-) I've run into problems in the past where I've
put pauses into my scripts and then forgotten to take them out before I
put the scripts into production...then I wonder why the scripts fail to
complete successfully :-)

Sandip Shah

unread,
Jan 7, 2011, 4:23:04 PM1/7/11
to Google Apps Manager
Normally, in a batch file one would send a status output to a text
file. Something like

echo 'such and such command completed successfully' >> results.txt

or

echo 'such and such command failed' >> results.txt

This way you can always check the results.txt file every morning.

A step forward - you can use vbscripts to mail that file to you.

I do not want to scare you away with all the possibilities of logging
(and there are a lot of logging facilities in Python that you can use
if you modify gam.py). At the end of the process you can have that
file mailed to you so that you can check the status of the process on
your phone if you are sitting in Africa. :-)

I would recommend getting this part of the project done, and then get
a smaller linux version running (even if it is in a virtual machine)
and move everything there. You'll get much more power on things that
you can do there. Not that you cannot do it on a windows machine, its
a bit harder there.

Ss

Gerard Duerrmeyer

unread,
Jan 7, 2011, 4:24:02 PM1/7/11
to google-ap...@googlegroups.com
What you are doing intrigued me so I had a further look.
I am not familiar with Windows Scheduler, however it may have the
capacity to e-mail the results of execution or display a log file so
that you can see whether something ran or not and if it ran, the
results from it running.
I quickly looked for easier windows cron alternatives and found:
- http://www.visualcron.com/Home.aspx (not free, but purports the
ability to e-mail report results, be remotely controlled over the
internet, other advanced features)
- http://www.z-cron.com/scheduler.html (free, does not e-mail on its
own but maintains a log file. You can likely achieve e-mail
functionality by using a commandline e-mail client)

In any case you may be able to achieve the "did it run" through other
means than leaving the console window open.

Cheers,

GD

Gretchen Nobles

unread,
Jan 7, 2011, 4:27:45 PM1/7/11
to google-ap...@googlegroups.com
Yes... a record of everything that was executed in a text file would be perfect!!!  That way I could just skim it and look out for any errors.  And you're saying that there is no way to do that in Windows?  I'm still a little scared of linux programming!!!  But maybe I'll get there eventually!!!

Sandip Shah

unread,
Jan 7, 2011, 4:34:35 PM1/7/11
to Google Apps Manager
No - that's not what I am saying.

You can output the status to a text file using the "echo" or the
"print" command and redirecting the output to a text file in Windows.

And you can also mail that file to yourself using vbscripts in
Windows.

But all this is rudimentary.

What you get on any variant of unix is much more powerful ... but then
the complexity is also a bit more, and not everyone needs all the
power.

All I am saying is start with this ... if it suffices, then look no
further. If it does not ...

Ss

Gerard Duerrmeyer

unread,
Jan 7, 2011, 4:39:35 PM1/7/11
to google-ap...@googlegroups.com
Well there may or may not be a "built-in" way in Windows. The two
programs I linked to provide solutions to being notified of the
completion as well as seeing the output of completion via e-mail, log,
other.

Modern cron daemons have this facility built-in where you can have any
output e-mailed automatically which makes what you are trying to
achieve very easy as you are not relying on any additional tools and
everything is literally built-in. But if you do not have a *nix
derivative machine handy, what others have mentioned may be preferable
at the moment.

I would explore the Task Scheduler further as it may write to a
windows log somewhere the results, I just haven't got an easy way to
test that. I talked to a buddy and he said he had used Z-Cron and that
it provided plenty good logging for what he was trying to achieve.

Also output redirection like Sandip mentioned is a simple solution. I
didn't know that worked in windows (I learn a lot of things from
watching this group).

Best of luck to you.

Cheers,

GD

RS

unread,
Jun 4, 2015, 7:16:31 AM6/4/15
to google-ap...@googlegroups.com
Hi i am beginner to GAM
please Guide me on how to run GAM command on a schedule to update users from CSV file. like user will update the csv file putting in details of user and later i will automatically get updated on scheduled time.

thank you best regards.

Ricardo Ardila Vetrovec

unread,
Jun 4, 2015, 8:03:59 AM6/4/15
to google-ap...@googlegroups.com
I use cron jobs on linux to do that ;)



--
You received this message because you are subscribed to the Google Groups "Google Apps Manager" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-man...@googlegroups.com.
To post to this group, send email to google-ap...@googlegroups.com.
Visit this group at http://groups.google.com/group/google-apps-manager.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-manager/25640c0f-4bef-4cc8-8407-79aa479f7a55%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--

--------------------------------------------------------------------------------------------------------



Chandrashekar N

unread,
Mar 21, 2018, 8:08:11 AM3/21/18
to GAM for G Suite
Hi Jay,

I would require your help in scheduling the task in windows server where users to be removed from the group who are inactive from 2days

Can we do this?

Regards,
Chandru


On Thursday, June 4, 2015 at 5:33:59 PM UTC+5:30, Ricardo Ardila Vetrovec wrote:
I use cron jobs on linux to do that ;)


2015-06-04 6:46 GMT-04:30 RS <raghunat...@searce.com>:
Hi i am beginner to GAM
please Guide me on how to run GAM command on a schedule to update users from CSV file. like user will update the csv file putting in details of user and later i will automatically get updated on scheduled time.

thank you best regards.
  

On Friday, January 7, 2011 at 11:31:33 PM UTC+5:30, Gretchen wrote:
Can anyone direct me to instructions for running GAM commands on a schedule?  I'd like set GAM to run commands to turn off webclips, pop, IMAP and email Forwarding automatically everyday.

Thanks!

--
You received this message because you are subscribed to the Google Groups "Google Apps Manager" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-manager+unsub...@googlegroups.com.



--

--------------------------------------------------------------------------------------------------------



Jay Strumwasser

unread,
Dec 14, 2018, 8:04:47 AM12/14/18
to GAM for G Suite
Good morning!  I would like to schedule gam to create a user account or suspend (depending on the need) based on a time.  Sometimes I get an email that says "shut off email at 5pm on Sunday" or othertimes, I get emails to create accounts for "7:30 Monday morning".  I am looking to do this away from my computer, but I cannot move users to correct OUs via mobile gadmin console.

Thank you!

Eric Dannewitz

unread,
Dec 14, 2018, 9:23:11 AM12/14/18
to google-ap...@googlegroups.com
Crontab?

Eric Dannewitz 
Technology Assistant
Acalanes Union High School District
District Office Technology Department


Challenge Preparatory Charter School Corporate Office
710 Hartman Lane
Far Rockaway, NY 11691

This is a staff email account managed by Challenge Preparatory Charter School.  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. If you have received this email in error please notify the sender.

--
You received this message because you are subscribed to the Google Groups "GAM for G Suite" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-man...@googlegroups.com.

To post to this group, send email to google-ap...@googlegroups.com.

Steve - DynTech

unread,
Dec 14, 2018, 12:17:34 PM12/14/18
to GAM for G Suite
Jay - I like to use at with gam for these types of situations. For example if I had that request today to shut off at 5pm this Sunday:

echo "/home/steve/bin/gamadv-xtd/gam update user lea...@domain.com gal off suspended on" | at 5pm + 2 days

Jay Strumwasser

unread,
Dec 14, 2018, 12:25:25 PM12/14/18
to GAM for G Suite

Jay Strumwasser

unread,
Dec 14, 2018, 12:29:45 PM12/14/18
to GAM for G Suite
Ok, great, I will try this.....can I do it on a win computer though?


On Friday, December 14, 2018 at 12:17:34 PM UTC-5, Steve - DynTech wrote:

Steve - DynTech

unread,
Dec 14, 2018, 12:44:02 PM12/14/18
to GAM for G Suite
As Jay Lee mentioned back in 2011 Scheduled tasks in Windows might be the way to go on that OS.

I would suggest using an always free f1-micro linux instance so you can use GAM from anywhere, anytime though.

Jay Strumwasser

unread,
Dec 14, 2018, 3:37:06 PM12/14/18
to GAM for G Suite

Jay Strumwasser

unread,
Dec 14, 2018, 3:39:42 PM12/14/18
to GAM for G Suite
@steve- DynTech -- since it is a school email, I do not want to attach a cc.  How can I do this?

Steve - DynTech

unread,
Dec 15, 2018, 11:29:22 AM12/15/18
to GAM for G Suite
I'm not entirely sure what you are asking but if I were to guess I'm thinking you want to cc someone on this thread...

Make sure you have email deliver for this group so you can respond via email and not just from the web then you can BCC anyone

+KimNilsson

unread,
Dec 17, 2018, 10:00:30 AM12/17/18
to GAM for G Suite
Nice, Steve!
Didn't know about th(at). :-)

/Kim
Reply all
Reply to author
Forward
0 new messages