ok...

U

user

I have written a script that read serial port (under linux). This
is done as per user specified interval. So we have,

while True:
readport()
processreading()
alertusers()
sleep(nseconds)


(the actuall code is more detailed)

I am currently thinking about reading the port and sending alerts
to users as part of a self test. What I am looking for is to specify a
date and time to run the self tests without interfering with anything
else i.e. the rest of the logic is not affected. Is this possible?

P.S. Cron can probably do the job, but I am trying to stick to python.
 
A

A.M. Kuchling

to users as part of a self test. What I am looking for is to specify a
date and time to run the self tests without interfering with anything
else i.e. the rest of the logic is not affected. Is this possible?

P.S. Cron can probably do the job, but I am trying to stick to python.

Why impose that last constraint? It seems much more difficult to write and
debug Python code for cron-like features than to just use cron.

Would your Python code run as a daemon and wait around until it's time to do
something? Then what if it crashes? You'd better implement logging of
errors so that you find out about any problems. What if the system gets
rebooted? You'd better write an /etc/init.d script to start your daemon.

It seems much easier to run 'crontab -e' and type in the following:

# Run the test every morning at 1AM
0 1 * * * /home/amk/test.py

--amk
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,170
Messages
2,570,925
Members
47,466
Latest member
DrusillaYa

Latest Threads

Top