How to make a python script run 15 minutes after system startup?
<p>I wrote a script a python which reminds me to open WhatsApp Web whenever chrome browser is opened. To run this script each time, I have to use the terminal to make the python script run. I want to make the script run automatically 15-20 minutes after the system starts. </p>

<p>Here's my code:</p>

<pre><code>import webbrowser
import os
import signal
import tkMessageBox
from subprocess import check_output
from crontab import CronTab


def get_pid(name):
    return int(check_output(["pidof","-s",name]))
'''Script to open whatsapp web whenever chrome is opened'''

cron=CronTab()
job=cron.new(command='/usr/bin/echo')
job.minute.during(1,50).every(1)
name="chrome"
if (get_pid(name)):
    webbrowser.open('http://web.whatsapp.com')
    tkMessageBox.showinfo(title="Greetings", message="Connect your         phone to chrome to open whatsapp!")
</code></pre>

<p>I tried editing the crontab, but that did not prove very helpful. Is there any way to do so?</p>

<p>Edit-1 
Here's my updated code, and it still doesn't seem to work. When I manually run the script, it works, but otherwise not(on reboot).</p>

<pre><code>    #!/usr/bin/env python
    import webbrowser
import os
import signal
import tkMessageBox
from subprocess import check_output
import time

def get_pid(name):
    return int(check_output(["pidof","-s",name]))


'''Script to open whatsapp web whenever chrome is opened'''

name="chrome"
while(1):
    time.sleep(600)
    while(get_pid(name)):
        webbrowser.open('http://web.whatsapp.com')
        tkMessageBox.showinfo(title="Greetings", message="Connect your phone to chrome to open whatsapp!")
        print "Hey"
</code></pre>

<p>Apart from this, I added the following lines in crontab:</p>

<pre><code>@reboot /usr/bin/python /path/to/whatsapp.py &amp;
</code></pre>

<p>Further, I made a .conf file which looks like this :</p>

<pre><code>start on runlevel [2345]
stop on runlevel [!2345]

exec /path/to/whatsapp.py
</code></pre>

<p>And the most recent log file for this looks like this:</p>

<pre><code>SyntaxError: invalid syntax
Traceback (most recent call last):
  File "/path/to/whatsapp.py", line 17, in &lt;module&gt;
    while(get_pid(name)):
  File "/path/to/whatsapp.py", line 10, in get_pid
    return int(check_output(["pidof","-s",name]))
  File "/usr/lib/python2.7/subprocess.py", line 573, in check_output
    raise CalledProcessError(retcode, cmd, output=output)
subprocess.CalledProcessError: Command '['pidof', '-s', 'chrome']' returned non-zero exit status 1
Traceback (most recent call last):
  File "/path/to/whatsapp.py", line 20, in &lt;module&gt;
    tkMessageBox.showinfo(title="Greetings", message="Connect your phone to chrome to open whatsapp!")
  File "/usr/lib/python2.7/lib-tk/tkMessageBox.py", line 83, in showinfo
    return _show(title, message, INFO, OK, **options)
  File "/usr/lib/python2.7/lib-tk/tkMessageBox.py", line 72, in _show
    res = Message(**options).show()
  File "/usr/lib/python2.7/lib-tk/tkCommonDialog.py", line 44, in show
    w = Frame(self.master)
  File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 2537, in __init__
    Widget.__init__(self, master, 'frame', cnf, {}, extra)
  File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 2049, in __init__
    BaseWidget._setup(self, master, cnf)
  File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 2024, in _setup
    _default_root = Tk()
  File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 1767, in __init__
    self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)
_tkinter.TclError: no display name and no $DISPLAY environment variable
</code></pre>

<p>where path/to is obviously the path to the script. </p>