Jump to content


Photo

Incompatibility with cron


  • Please log in to reply
1 reply to this topic

#1 Eric Newbauer

Eric Newbauer

    Advanced Member

  • KB Moderators
  • PipPipPip
  • 258 posts

Posted 28 September 2006 - 05:04 PM

Symptom
You have written a script that manually executes OK but the script fails with cron.

Resolution
This is a known issue. SANmp's Command Line Interface (CLI) is incompatible with cron. A workaround is to use Apple's iCal application, which can be configured to schedule the routine processing of a script.

Edited by Moderator, 28 September 2006 - 05:08 PM.

Eric Newbauer, SNS Moderator
----
Learn about our SAN/NAS shared media storage products
Follow Studio Network Solutions on Twitter

#2 SNSjason

SNSjason

    Advanced Member

  • KB Moderators
  • PipPipPip
  • 36 posts

Posted 14 February 2012 - 01:31 PM

In recent versions of OS X, launched has superseded the cron utility. SANmp CLI mode works well with this method of launching.

As an example, I have created the following script, which will log in to SANmp, mount Vol1 and Vol2 as RW, and then create a file on each, named for the current date and time. It then unmounts them and logs out.

#!/bin/bash
VOLS="Vol1 Vol2"
/opt/local/bin/SANmpClient login 1 1
for VOL in $VOLS; do
	    /opt/local/bin/SANmpClient mount volume $VOL RW
	    touch /Volumes/$VOL/`date +'%Y-%m-%d_%H-%M'`
	    /opt/local/bin/SANmpClient unmount volume $VOL
done
/opt/local/bin/SANmpClient logout

In the home directory of my user ("admin"), I created a directory called "bin", and placed this script inside that with a filename of SANmpTag.bash. I then made the script executable with "chmod".

Next, I created a directory at ~/Library/LaunchAgents which the launchd process scans for plist files. I created the following file with a name of com.studionetworksolutions.SANmpTag.plist

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
  <key>Label</key>
  <string>com.studionetworksolutions.SANmpTag</string>

  <key>ProgramArguments</key>
  <array>
    <string>/Users/admin/bin/SANmpTag.bash</string>
  </array>

  <key>Nice</key>
  <integer>1</integer>

  <key>StartInterval</key>
  <integer>600</integer>

  <key>RunAtLoad</key>
  <true/>

  <key>StandardErrorPath</key>
  <string>/tmp/SANmpTest1.err</string>

  <key>StandardOutPath</key>
  <string>/tmp/SANmpTest1.out</string>
</dict>
</plist>

This launchd plist will execute the script every 10 minutes (600 seconds), and redirect the output to a couple files in the /tmp/ directory.