Cron Job Syntax

176 views
Skip to first unread message

Mischa Friegang

unread,
May 13, 2019, 5:02:06 PM5/13/19
to GAM for G Suite
I'm pretty new to linux and I'm trying to set up a cron job that resets a users password once a week. I know what the gam command would be, but it doesn't seem to be running the command on schedule. Any ideas as to what I'm doing wrong?
Here's what I have in my crontab file:  #46 1 * * 1  gam update user test@****.org password test1234
Do I need to point to my gam install under /home/usr/bin/gam?
Thanks in advance 

Ross Scroggs

unread,
May 13, 2019, 5:26:53 PM5/13/19
to google-ap...@googlegroups.com
Mischa,

Yes, use the full path.

Ross

CONFIDENTIALITY NOTICE:
This e-mail message, including any attachments, is intended for the sole use of the intended recipient(s) to whom it is addressed and may contain information that is legally privileged, confidential and exempt from disclosure under applicable law. If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution, use and or taking any action on reliance on the contents of this electronic mail message, confidential information is strictly prohibited (Fed Reg 42CFR, part 2). If you have received this e-mail in error, please notify us immediately or arrange for return of the original electronic mail transmission.

--
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.
Visit this group at https://groups.google.com/group/google-apps-manager.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-manager/23c5fb7e-c06e-4788-9ae0-f1998fbb096f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--

Matthew Uribe

unread,
May 13, 2019, 5:31:05 PM5/13/19
to GAM for G Suite
Mischa,

It looks like your schedule will run at 1:46 am on day 1 (Monday) of each week. However, you have commented the line out, so it's going to be ignored. Try removing the # from the beginning of the line.

Matt

Mischa Friegang

unread,
May 13, 2019, 5:48:08 PM5/13/19
to GAM for G Suite
Whoops, you're right I definitely had it commented it out, thanks for the response. I have taken the comment out but i still does not seem to be running.  Where in the command would I want to point to my GAM installation? 

Eric Dannewitz

unread,
May 13, 2019, 6:03:47 PM5/13/19
to 'James SEYMOUR' via GAM for G Suite
gam

so you have to put your path to gam there

46 1 * * 1 /usr/local/gamadv-xtd/gam update user test password test1234

CONFIDENTIALITY NOTICE:
This e-mail message, including any attachments, is intended for the sole use of the intended recipient(s) to whom it is addressed and may contain information that is legally privileged, confidential and exempt from disclosure under applicable law. If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution, use and or taking any action on reliance on the contents of this electronic mail message, confidential information is strictly prohibited (Fed Reg 42CFR, part 2). If you have received this e-mail in error, please notify us immediately or arrange for return of the original electronic mail transmission.

--
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.
Visit this group at https://groups.google.com/group/google-apps-manager.

For more options, visit https://groups.google.com/d/optout.


--
Eric Dannewitz 
Technology Assistant/District Tech
Acalanes Union High School District
District Office Technology Department

Matthew Uribe

unread,
May 13, 2019, 6:07:32 PM5/13/19
to GAM for G Suite
Mischa,

Have you updated the schedule to cause it to have run just now? You could append something to the crontab so that it saves all of its output into another file, so that you can see if it's running, and what it's doing. Try updating your crontab entry as follows:

46 1 * * 1  gam update user test@****.org password test1234 > ~/cron.log 2>&1

After your scheduled time, the file cron.log in the user's home directory should contain all output from the command, standard and error. This way, if there's an error, such as "-bash: flam: command not found", then you'll know what the problem is.

As far as the path to the gam command, you might try "locate gam" or "which gam" to see where your gam install is. 

One final thought: I'm not sure which flavor of Linux you're using, or if it even matters, but in my experience, crontab expects a blank line at the end of the crontab file. Does your crontab file have a blank line at the end?

Matt

Mischa Friegang

unread,
May 13, 2019, 6:33:18 PM5/13/19
to GAM for G Suite
Yes I've tried it with current time, as well as adding the blank line at the end of the crontab. Here's what I'm trying now:  27 15 * * * home/usr/bin/gam gam  update user test@****.org password 1234 ~/cron.log 2>&1
I'm not seeing the log file getting saved anywhere. I am going to try with some more basic crontabs (not involving GAM, just basic text outputs) and move up from there. Thanks again for responding. You're leading me in the right direction 

Eric Dannewitz

unread,
May 13, 2019, 6:34:57 PM5/13/19
to google-ap...@googlegroups.com
Incorrect. 

you need to change to

/home/usr/bin/gam 

NOT

/home/usr/bin/gam gam



CONFIDENTIALITY NOTICE:
This e-mail message, including any attachments, is intended for the sole use of the intended recipient(s) to whom it is addressed and may contain information that is legally privileged, confidential and exempt from disclosure under applicable law. If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution, use and or taking any action on reliance on the contents of this electronic mail message, confidential information is strictly prohibited (Fed Reg 42CFR, part 2). If you have received this e-mail in error, please notify us immediately or arrange for return of the original electronic mail transmission.

-- 
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.
Visit this group at https://groups.google.com/group/google-apps-manager.

Mischa Friegang

unread,
May 13, 2019, 6:42:27 PM5/13/19
to GAM for G Suite
The second "gam" was the first part of the gam command, not the file path. Does the command not need to start with gam? EG: gam update user test@***.org password test1234   
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-manager+unsub...@googlegroups.com.

Ross Scroggs

unread,
May 13, 2019, 6:45:01 PM5/13/19
to google-ap...@googlegroups.com
You want: 27 15 * * * /home/usr/bin/gam/gam  update user test@****.org password 1234 ~/cron.log 2>&1
I'm assuming that usr is a placeholder, replace with your actual user name

Ross


To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-man...@googlegroups.com.
CONFIDENTIALITY NOTICE:
This e-mail message, including any attachments, is intended for the sole use of the intended recipient(s) to whom it is addressed and may contain information that is legally privileged, confidential and exempt from disclosure under applicable law. If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution, use and or taking any action on reliance on the contents of this electronic mail message, confidential information is strictly prohibited (Fed Reg 42CFR, part 2). If you have received this e-mail in error, please notify us immediately or arrange for return of the original electronic mail transmission.

--
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.
Visit this group at https://groups.google.com/group/google-apps-manager.

For more options, visit https://groups.google.com/d/optout.


--

Matthew Uribe

unread,
May 13, 2019, 6:52:48 PM5/13/19
to GAM for G Suite
Have you tried a "locate gam" or "which gam" to get the path to the executable? /home/usr seems a little unusual. Commonly, in Linux systems, there is a /home and a /usr, and it is entirely possible that there is a /home/usr, but it seems worth checking. 

The ~/cron.log should be in the user's home directory. Try "cd ~" and then "ls". You should see the cron.log file. If not, perhaps the ~/ shortcut does not work in the cron environment. Changing ~/cron.log to the full path for your user, such as "/home/usr/cron.log" might be necessary.

Eric Dannewitz

unread,
May 13, 2019, 6:54:19 PM5/13/19
to 'James SEYMOUR' via GAM for G Suite
all you need to do is

root@dvecgam01:~/CalendarBackups# gam

GAM 4.82.11 - https://github.com/taers232c/GAMADV-XTD
Ross Scroggs <ross.s...@gmail.com>
Python 2.7.16 64-bit final
google-api-python-client 1.7.8
httplib2 0.12.1
oauth2client 4.1.3
Linux-4.15.0-48-generic-x86_64-with-Ubuntu-18.04-bionic x86_64
Path: /usr/local/gamadv-xtd
Help: Syntax in file /usr/local/gamadv-xtd/GamCommands.txt
Help: Documentation is at https://github.com/taers232c/GAMADV-XTD/wiki

Gam tells you where it is (or at)

--
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.
Visit this group at https://groups.google.com/group/google-apps-manager.

For more options, visit https://groups.google.com/d/optout.


--

Mischa Friegang

unread,
May 13, 2019, 8:58:02 PM5/13/19
to GAM for G Suite
I decided to check the system time on my google cloud VM that I use to run GAM and now I feel like an idiot. I should have checked to see what time the system was running off off instead of just using my local time. Turned out to be in a different time zone. It seems to be working as it should now. Thanks to everyone for the responses, I can't overstate how thankful I am for GAM and this community. Cheers 
Reply all
Reply to author
Forward
0 new messages