About Beckman

I'm a big geek, serial entrepreneur and idea guy. I've been called names, such as PHP Guru, MySQL DBA, BOFH, Security God, etc. That and Peter-Peter-Pumpkin-Eater.

The image in the header is © Peter Beckman.

Archives

01 Jan - 31 Jan 2003
01 Feb - 28 Feb 2003
01 Mar - 31 Mar 2003
01 Apr - 30 Apr 2003
01 May - 31 May 2003
01 Jun - 30 Jun 2003
01 Jul - 31 Jul 2003
01 Aug - 31 Aug 2003
01 Sep - 30 Sep 2003
01 Oct - 31 Oct 2003
01 Feb - 28 Feb 2004
01 Jul - 31 Jul 2004
01 Aug - 31 Aug 2004
01 Oct - 31 Oct 2004
01 Mar - 31 Mar 2005
01 Apr - 30 Apr 2005
01 May - 31 May 2005
01 Jun - 30 Jun 2005
01 Jan - 31 Jan 2006
01 Jun - 30 Jun 2006
01 Feb - 28 Feb 2007
01 Apr - 30 Apr 2007
01 Sep - 30 Sep 2007
01 Mar - 31 Mar 2008
01 May - 31 May 2008
01 Jul - 31 Jul 2013
01 Sep - 30 Sep 2013
01 Apr - 30 Apr 2014
01 Jul - 31 Jul 2014
01 Dec - 31 Dec 2014
01 Dec - 31 Dec 2015

Links

AngryOx.com
Tossable Digits - Cheap, Anonymous, Disposable Phone Numbers
The Internet License Plate Database
Love & Onions (Jen, my wife)
Roadie Speaks Blog
BananaForce
AdCritic.com
Slashdot
I Love Ben Brown

Search!

Last Comments

marshakaplan766 (Renaming your OSX…): Renaming your OSX Home Di…
GoaDarling (Wow, I'm fat.): Embark on an unforgettabl…
John smith (Centrum Silver Ad…): The Centrum Silver Ad has…
John smith (Centrum Silver Ad…): Centrum Silver ads often …
merryjhon (Centrum Silver Ad…): The Centrum Silver ad flo…
Hairmond (Wow, I'm fat.): Hairmond specializes in t…
MyCleanRServices (Wow, I'm fat.): MyCleanRServices is your …
RKCoatings (Wow, I'm fat.): RK Coatings brings life t…
TrustWorthy (Wow, I'm fat.): Trust Worthy offers the c…
GoaDarling (Wow, I'm fat.): Discover the magic of Goa…

Stuff

Powered by Pivot - 1.40.1: 'Dreadwind' 
XML: RSS Feed 
XML: Atom Feed 

« Quicksilver and OTP: … | Home |

How to log cron jobs in OS X El Capitan 10.11

Wednesday 09 December 2015 at 10:05 am

Last night I wrote a quick PHP script to scan the OVH, SoYouStart and Kimsufi dedicated server inventory to alert me via email when certain types of servers in specific datacenters became available.

After decoding the server type ID and building SASL and TLS authentication into Postfix, I added the script to cron. But I wasn’t sure it was running, and while on most servers there’s a cron log, there wasn’t one on my Mac Pro. How to get it there…

My first thought was syslog. So I looked at /etc/syslog.conf:

  # Note that flat file logs are now configured in /etc/asl.conf
  install.*						@127.0.0.1:32376

Well that’s not helpful. What’s this asl.conf? I sure didn’t know, but a little digging found me this gem:


It looks like aslmanager first appeared in OS X 10.5.6. It also looks like the asl facility is Apple’s replacement for syslogd, created to make it easier to quickly search system logs. From the asl(3) man page: “This API permits clients to create queries and search the message data store for matching messages.”

So asl is the OSX way to manage log files. Great! Let’s learn it.

  ##
  # configuration file for syslogd and aslmanager
  ##

# aslmanager logs > /var/log/asl/Logs/aslmanager external style=lcl-b ttl=2 # authpriv messages are root/admin readable ? [= Facility authpriv] access 0 80 # remoteauth critical, alert, and emergency messages are root/admin readable ? [= Facility remoteauth] [<= Level critical] access 0 80

What is this sorcery?!? I kid, it’s actually a well organized configuration language. The meat of it is the leading character of each line. From the asl.conf man page:

The files contain several types of lines, described below. Each type is identified by the first non-whitespace character in the line.

     =  Parameter settings
     ?  Query-action rules
     >  Output file or directory configuration options
     #  Comments

So lines that start with a “>” deal with files that will be used for logging, and lines that start with an “=” indicate what syslog entries go into what files. That’s all I needed. So here’s what I added to my asl.conf:

 # Cron!
 > cron mode=0640 format=bsd rotate=seq compress file_max=5M all_max=50M
 ? [= Facility cron] [<= Level info] file cron

  1. Line 1: A comment!
  2. Line 2:
    1. Name of log File
    2. File Permissions
    3. Log using syslogd format (bsd is one of many logfile formats asl supports)
    4. Rotate log files using sequential names e.g. system.log becomes system.log.0 on rotation
    5. Compress the file using gzip upon rotation
    6. Rotate when the file grows more that 5MB in size
    7. Start deleting rotated files when the sum of filename.*.gz exceeds 50MB
  3. Line 3:
    1. If the syslog facility equals cron
    2. AND the syslog level is info or above (greater)
    3. Log the syslog message into the file named cron

That’s it! Then I restarted both syslog and aslmanager, not knowing which one (or both) needed to re-read the asl.conf:

  sudo launchctl stop com.apple.syslog
  sudo launchctl stop com.apple.aslmanager
  sudo launchctl start com.apple.syslog
  sudo launchctl start com.apple.aslmanager

And now things are working just the way I like.


  Dec  9 09:45:00 max /usr/sbin/cron[8363]: (beckman) CMD (/usr/bin/php /Users/beckman/bin/ovh-watch.php)
  Dec  9 09:50:00 max /usr/sbin/cron[8380]: (beckman) CMD (/usr/bin/php /Users/beckman/bin/ovh-watch.php) 
  Dec  9 09:55:00 max /usr/sbin/cron[8398]: (beckman) CMD (/usr/bin/php /Users/beckman/bin/ovh-watch.php)


I hope this helps you! If so, or if you have questions, leave them in the comments below.


17 comments

I really loved the way you written this post. It have some really intersting contents. I like to read articles and novel in my free time. This blog is one of my favourite. Keep sharing more helpful and informative posts. Thank you for this wonderful post. I really enjoyed the way you wrote this post. The contents are written in a good manner and all the wordings are very easy to understand. Refer essay writing service reviews to get reviews of various online writers.
Anne F (Email) - 27 12 16 - 02:26

Thanks, very helpful but where do your cron logs end up?
Alex (Email) - 05 02 17 - 19:04

I have known very important things over here. I want to thank you for this educational read. I really appreciate sharing this great.
best essay writing service (Email) (URL) - 27 09 17 - 07:17

I tried this and got syntax errors in my syslog file. After some twiddling, I think the actual asl.conf entry ought to look more like this:

#log cron jobs
? [= Facility cron] [
Paul Clearfire - 08 12 17 - 13:14

For some reason this service did not post all of my text above….

pc
Paul Clearfire (Email) - 08 12 17 - 13:21

Wholesale party supplies is a place where you can find different groceries, items and appliances at one place.
[Aesh A] - 17 03 20 - 06:53

Look for a college paper example? You can find tons of samples of various academic assignments on this website. They are free to use.
Nicolle Meyer - 03 07 20 - 04:32

I must appreciate the way you have expressed your feelings through your blog.
Technical information (Email) (URL) - 17 12 20 - 04:05

This separated, by smoothing out the back-office tasks of class the board, free teachers and establishments can dedicate more opportunity to center homeroom exercises. They can think of better thoroughly examined modules, focus more on showing quality, and give more opportunity to collaborating with their understudies eye to eye or online which isn’t given that genuinely necessary accentuation is a customary study hall arrangement. All these assistance to do an extraordinary worth expansion to the whole part of instructing.

do my class for me
Libby Howells (Email) - 14 01 21 - 02:13

You’ll improve your grades and feel like a new person right after crafting an impressive creative essay . Getting top grades is easy if you are aware of all the nuances.
Sylvia99 - 31 03 21 - 06:00

nice post like it
shan aan (Email) (URL) - 03 06 21 - 07:44

good post like it https://www.angryox.com/blog/entry/53/how_to_log_cron_jobs_in_os_x_e/my_weblog#message
yallau yallau (Email) - 26 08 21 - 07:07

good work like it
samlio sha (Email) - 26 08 21 - 07:08

good post like [url=https://www.google.com/]it[/url]
try
[try](https://www.google.com/)
samwts shan (Email) - 26 08 21 - 07:09

The Precious Pouch is Hand Made by Cate with Love. Cate will make your Precious Pouch however you want it, from a great range of colorful and vibrant designs. The Precious Glassware Australia are made from a high-quality water-resistant canvas fabric that is both water and light-resistant.
kavinliny (Email) (URL) - 15 09 21 - 11:09

I have been checking out a few of your stories and i can state pretty good stuff. I will definitely bookmark your blog
new (Email) (URL) - 18 11 21 - 07:41

2022 is full of music, sports, and space events. If you are living in the USA and want to enjoy the events in the coming month of november, then this post is for you. In this post, we are going to share with you the upcoming mega USA events in November 2022. So, stick around to get to know about the events. https://why-and-how.co/usa-events-in-november/
Reghla Carter (Email) (URL) - 30 07 22 - 02:41


Trackback link:

Please enable javascript to generate a trackback url

  
Remember personal info?

Emoticons / Textile

To prevent automated comment-spam, we require you to answer this silly question.
 

  (Register your username / Log in)

Notify:
Hide email:

Small print: All html tags except <b> and <i> will be removed from your comment. You can make links by just typing the url or mail-address.