Author Topic: Run a Script after Login  (Read 5497 times)

cdusseau

  • Newbie
  • *
  • Posts: 4
Run a Script after Login
« on: October 28, 2010, 20:11:23 PM »
I am writing a simple script to autoupdate some files on a usb drive from a network share. I need this script to run right after login and the connection to the network is up.

I honestly am not that familiar with any sort of task scheduling in Linux, but I already tried rc.local and it executes it too early (before net connection is up).

I can't find a cron (the fact that Im looking for one might speak to my ignorance) and I'm not sure how to use the rc.d system if that would work for me.

I know this is something a lot of you consider common knowledge, so please take a minute and help me out =)

Thanks.

Elmar

  • Administrator
  • Hero Member
  • *****
  • Posts: 2450
  • a command shell is enough to do amazing things
Re: Run a Script after Login
« Reply #1 on: October 28, 2010, 20:31:53 PM »
hi,
I honestly am not that familiar with any sort of task scheduling in Linux, but I already tried rc.local and it executes it too early (before net connection is up).

the network is started with rc.local. place your script at the end of rc.local and it should work

regards
elmar

cdusseau

  • Newbie
  • *
  • Posts: 4
Re: Run a Script after Login
« Reply #2 on: October 28, 2010, 20:44:45 PM »
I tried that and got this as a result:

Connection to image-server failed (Error NT_STATUS_BAD_NETWORK_NAME)

But, if I execute the exact same script after login it connects and performs its function just fine. I said I was having issues with the connection not being ready because after the autologin I get a few lines about eth0. They tell me a few things about the link being ready, not ready and then ready again. After it becomes ready the second time my script works great.

Any way to delay the execution until the network is up? Aka detect if link is down or up and keep trying until it is up.

Elmar

  • Administrator
  • Hero Member
  • *****
  • Posts: 2450
  • a command shell is enough to do amazing things
Re: Run a Script after Login
« Reply #3 on: October 28, 2010, 21:01:40 PM »
you can check it with dmesg|grep "eth0: link becomes ready" in a while loop

cdusseau

  • Newbie
  • *
  • Posts: 4
Re: Run a Script after Login
« Reply #4 on: October 28, 2010, 21:07:49 PM »
Thanks for the input, its working great now.

BTW I truly love this distribution, its perfect for my needs!

Elmar

  • Administrator
  • Hero Member
  • *****
  • Posts: 2450
  • a command shell is enough to do amazing things
Re: Run a Script after Login
« Reply #5 on: October 28, 2010, 21:10:58 PM »
nice to hear that its useful :)

best regards
elmar