Auto-login Multiple users who then launch a script

Discussion in 'Mac OS X Server, Xserve, and Networking' started by RobQuads, Oct 8, 2013.

  1. RobQuads macrumors regular

    Joined:
    Jul 11, 2010
    #1
    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?
     
  2. MacUser2525 macrumors 68000

    MacUser2525

    Joined:
    Mar 17, 2007
    Location:
    Canada
    #2
    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.
     
  3. alexrmc92 macrumors regular

    Joined:
    Feb 7, 2013
    #3
    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.
     
  4. MacUser2525 macrumors 68000

    MacUser2525

    Joined:
    Mar 17, 2007
    Location:
    Canada
    #4
    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
    
     
  5. alexrmc92 macrumors regular

    Joined:
    Feb 7, 2013
    #5
    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.
     
  6. MacUser2525 macrumors 68000

    MacUser2525

    Joined:
    Mar 17, 2007
    Location:
    Canada
    #6
    Your script takes care of running the app which you would launch before doing others things needed by it.
     
  7. alexrmc92 macrumors regular

    Joined:
    Feb 7, 2013
    #7
    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.
     

Share This Page