Since a number of users seem to be struggling with the conversion to Solaris, I thought I would share the scripts I have been using to start my Python bots from Solaris cron using the job server. If you want to use these, be sure to substitute your username for "username" in the last line of listing 1, and your python path (if you have one defined) in the third line of listing 2.
With these scripts in your home directly, you can then set up a cron job to run any Python script using the following syntax in your crontab:
30 9 * * * $HOME/pysub jobname $HOME/path/script.py arg1 arg2
"jobname" is an arbitrary name to be given to the job. Be sure to include $HOME/ in both places; replace /path/ with the path from your home directory to the Python script.
I don't know as much about bash as I do about Python, so it is very possible someone else can improve on these scripts. :-) But feel free to use them if they are helpful.
Russ
Listing 1: pysub
#! /bin/ksh # like cronsub, but runs a python script instead of a shell script . /sge62/default/common/settings.sh [[ $# -ge 1 ]] || { echo >&2 "usage: $0 <jobname> <script>" exit 1 } JOBNAME=$1 shift SCRIPT=$@ qstat -j $JOBNAME >/dev/null 2>&1 || qsub -N $JOBNAME /home/username/py.sh $SCRIPT >/dev/null
Listing 2: py.sh
#!/bin/sh # run an arbitrary Python script PYTHONPATH=/copy/of;/your/pythonpath export PYTHONPATH /usr/bin/python $@
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
Russell Blau:
With these scripts in your home directly, you can then set up a cron job to run any Python script using the following syntax in your crontab:
30 9 * * * $HOME/pysub jobname $HOME/path/script.py arg1 arg2
What feature(s) does this provide that cronsub doesn't?
- river.
I was never able to get cronsub to accept arguments to the Python script; perhaps I was doing it wrong, but this worked so I stopped worrying about it.
----- Original Message ----- From: "River Tarnell" river.tarnell@wikimedia.de To: toolserver-l@lists.wikimedia.org Sent: Thursday, January 06, 2011 1:39 PM Subject: Re: [Toolserver-l] Submitting Python jobs to SGE from cron
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
Russell Blau:
With these scripts in your home directly, you can then set up a cron job to run any Python script using the following syntax in your crontab:
30 9 * * * $HOME/pysub jobname $HOME/path/script.py arg1 arg2
What feature(s) does this provide that cronsub doesn't?
- river.
-----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (FreeBSD)
iEYEARECAAYFAk0mDFAACgkQIXd7fCuc5vJCaQCeO8xJQypYe6p4y08ijt7/2gl2 wngAn0CbmLG4nie6bNqPs7EDJYc8clZZ =7wHw -----END PGP SIGNATURE-----
Toolserver-l mailing list (Toolserver-l@lists.wikimedia.org) https://lists.wikimedia.org/mailman/listinfo/toolserver-l Posting guidelines for this list: https://wiki.toolserver.org/view/Mailing_list_etiquette
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
Russell Blau:
I was never able to get cronsub to accept arguments to the Python script;
This seems to work fine for me:
willow% cat test.py #!/usr/bin/python #$ -j y #$ -o $HOME/test.out import sys print sys.argv willow% cronsub test test.py a b c willow% tail ~/test.out ['/sge62/default/spool/wolfsbane/job_scripts/114704', 'a', 'b', 'c']
I think we fixed cronsub some time ago to allow arguments, both to qsub and the script itself. (Did you ever report this problem to us?)
- river.
toolserver-l@lists.wikimedia.org