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.


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


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


Last Comments

Women Leather Jac… (Half-Life mod "Sv…): All buys are spared to yo…
The Academic Pape… (How to fix your D…): Many new learners face th…
proessaywritingse… (Centrum Silver Ad…): You need to realize the s…
Bookkeeping Assig… (Centrum Silver Ad…): I have perused in each of…
Affiliate for Ess… (How to fix your D…): The underlying principles…
UK online essay h… (How to fix your D…): Amazing your all post is …
UK nursing essay … (How to fix your D…): We are the best assignmen…
DissertationUK (How to fix your D…): We have been serving stud…
Amanda (How to fix your D…): Most authenticator applic…
Nicolle Meyer (Quicksilver and O…): I was tired of racking my…


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.*						@

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.

seven 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….

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

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)

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.