Cron permissions on Princeton’s servers

Posted Monday, February 9, 2009 at 14h08 in Personal

So I’m trying to create a subscriptions feature for the new Manna website that I’ve been overworking myself on for the past several months. Seriously, if I applied my hourly rate from my last job to the number of hours I’ve spent on that site, I’d have made about… $28,000. Yikes, I just calculated that and even I’m surprised. Anyway, back to the topic. The website has user generated content– blogs, wall (think facebook), photos– and I wanted to allow users to subscribe to content from other users. The steps involved:

  1. Creating a database for subscriptions data (easy)
  2. Creating a front-end for users to add/modify/delete subscriptions (time consuming but straightforward)
  3. Checking new content against the subscriptions table and sending out emails accordingly.

For this last step, there were two methods I could take:

  • Write a hook for the classes that save new content to the database
  • Write a stand alone script that periodically checks new content in the db, and add the script to a cron job

I started with the first option, but soon realized that because users can set a future “publish date” for their items, the hook idea wouldn’t work, since it can only take action at the time that the content is created or modified. The idea is for subscribers to be notified whenever content is “published,” which does not have to coincide with when they are created.

So, I had to pursue the second option. The funny thing about Princeton’s server is that the user account does not have access to its own database. (Right now you should be saying, “wtf?!”) Apparently the user accounts are stored on one server, and httpd, mysql, and other web services are run off another server. The user accounts on the first server have access to the second server via a pseudo clone account, which gives you a home directory and lets you edit files, etc. However, only accounts native to the second server (i.e. apache) have access to the database. That means any script you add to your cron (which is stored on the first server) will not have permission to access the database, which makes option (2) impossible. Unless, of course, I’m a genius (haha, ok, I’m not, but let me gloat here for once. I’ve just realized I’ve given up over $28k for something I’m basically doing pro bono, and it’s making me feel nauseous, so I’ll take whatever delusional ideas of self grandeur I can that will take my mind off that.) Anyway, my solution was to use wget to make apache run the script instead of the local user, and add the wget to the cron. That way, the script is always run by apache which does have access to the database. Problem solved.

2 Comments »

Comment from ruach on February 20, 2009 at 4:15 pm

if it’s any consolation, 28k is more than i make in a whole YEAR. :(

Comment from stevec on February 20, 2009 at 4:37 pm

but you are getting priceless experiences as a student at the best university in the universe. :)

RSS feed for comments on this post | TrackBack URI

Leave a comment

XHTML: You can use these tags:

<a href="" title="">
<abbr title="">
<acronym title="">
<b>
<blockquote cite="">
<cite>
<code>
<del datetime="">
<em>
<i>
<q cite="">
<strike>
<strong>