Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

RobQuads

macrumors regular
Original poster
Jul 11, 2010
234
48
Is there a way to get multiple users to log in to a desktop session and then launch a script?

You may ask why would be want to do this?

We want to run a number of test clients on our server. Each test client needs to run as its own user via a normal interactive login session

Using Fast User Switching and VNC I can log in each one and then startup up the test client but we want to be able to do this automatically.

Any ideas?
 

MacUser2525

Suspended
Mar 17, 2007
2,097
377
Canada
A cron job perhaps when I was looking into this the other day for my linux server I have I noticed an @reboot option for it which allows you to run a command/script as that user every time the machine starts. If OSXs cron supports this you could possibly use that for your needs.
 

alexrmc92

macrumors regular
Feb 7, 2013
218
0
A cron job perhaps when I was looking into this the other day for my linux server I have I noticed an @reboot option for it which allows you to run a command/script as that user every time the machine starts. If OSXs cron supports this you could possibly use that for your needs.

cron was depreciated by launchd in 10.4

launchd can start scripts and run them as any user you want without having to log in. If you require the guy for these scripts then the only way to do it is by hand.
 

MacUser2525

Suspended
Mar 17, 2007
2,097
377
Canada
cron was depreciated by launchd in 10.4

launchd can start scripts and run them as any user you want without having to log in. If you require the guy for these scripts then the only way to do it is by hand.

Still seems to be there all these releases later...

Code:
MacUser2525:~$ crontab -e
crontab: no crontab for MacUser2525 - using an empty one
crontab: no changes made to crontab
 

alexrmc92

macrumors regular
Feb 7, 2013
218
0
Still seems to be there all these releases later...

Code:
MacUser2525:~$ crontab -e
crontab: no crontab for MacUser2525 - using an empty one
crontab: no changes made to crontab

Yes it's still there, but it is depreciated. It's probably in mavericks too. It's similar to how ipfw was replaced by pf. ipfw is still there, but everything uses pf.

An issue you might run into is that cron is lauched via launchd. launchd doesn't start things in any particular order or wait for something to finish starting. So you could end up starting cron before the application you need to script is up and running and your script will generate an error.
 

MacUser2525

Suspended
Mar 17, 2007
2,097
377
Canada
Yes it's still there, but it is depreciated. It's probably in mavericks too. It's similar to how ipfw was replaced by pf. ipfw is still there, but everything uses pf.

An issue you might run into is that cron is lauched via launchd. launchd doesn't start things in any particular order or wait for something to finish starting. So you could end up starting cron before the application you need to script is up and running and your script will generate an error.

Your script takes care of running the app which you would launch before doing others things needed by it.
 

alexrmc92

macrumors regular
Feb 7, 2013
218
0
Your script takes care of running the app which you would launch before doing others things needed by it.

It depends on what your doing, for most cases cron will probably work fine. But for instance if you needed to script a telnet session to postfix you would end up running the risk of cron getting started before postfix which would prevent the script from working correctly.

I'm not saying that cron wont work or is a bad choice, i am just saying that the way apple implements it in newer versions of OS X isn't always ideal. Eventually cron may not be included with OS X anymore.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.