1

I'm running my Raspberry Pi off an SSH server, and want to be able to access it out of home. Sure, all I need is an IP. But with my terrible internet, it's constantly dropping out. My IP is constantly changing.

To counteract this, I setup a script to test if my IP is the same as it was 30 minutes ago, every 30 minutes. I also have a script set to kill this, so it doesn't go on forever or until reboot.

How can I make my process run itself in the background, without user interaction via. regex like nohup? Can nohup be self-automated? I want this functionality so I don't need an extra computer open while away. (Again, I'm accessing my Pi from SSH)

  • I am not sure if Pi support crond or not. But I hope you can install and manage it. – pmverma Aug 19 '15 at 8:15
  • @pmverma Just checked, not installed. Should I just apt-get? How would I use it? – user129109 Aug 19 '15 at 8:56
  • @pmverma I do have cron. – user129109 Aug 19 '15 at 8:57
  • Well you can run your script every 30 minutes background process. – pmverma Aug 19 '15 at 8:59
  • @pmverma I'm sorry? What? I use cron every 30 minutes yes, but not in the background... I don't understand what your saying? – user129109 Aug 19 '15 at 9:01
0

use the following to run command in background, it detaches from terminal

nohup command &

or if running command from termial, to put in background do:

command

then ctrl+z on keyboard to suspend current process, then type:

bg

to push suspended process to background. type:

jobs

to list current jobs, including your background process. type:

fg %n

where n in job number from jobs command.

nohup command & can easily be scripted.

  • Firstly, nohup command & gave me an error. I can give it to you if you want. Secondly, how would I execute CTRL+Z in a script? – user129109 Aug 19 '15 at 9:00
  • Can you please give me an example of the script in use? – user129109 Aug 19 '15 at 9:00
2

If you have installed crontab then type command crontab -e And write following

30 * * * * /home/user/ipcheck.sh

This will run ipcheck.sh every 30 minute in background.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy