I'm running the following python code:
import os
day='09'
month='08'
year='2016'
hours='14'
minutes='30'
seconds='00'
dt="sudo date -s '" + day + " " + month + " " + year + " " + hours + ":" + minutes + ":" + seconds + "'"
os.system(dt)
when I run this script, it always work true and set my raspberry pi date and time correctly, but the problem is that it takes very very long time to execute most of the time. if I write a simple print command after calling os.system(dt), it cost me more than 10 seconds to see the print command output and some times it cost less than a second (but this happens rarely).
Knowing that all my tries are done with same parameters, and some of these tries executed in less than a second and most of them executed in more than 10 seconds. This means that the problem is not with a wrong date/Time parameter value.
Any suggestions will be so appreciated
Note: I tried to run another script that prints some text every 1 second, and then I ran the above script when it reached os.system(dt), the second seperated script freezed as well as the above one. which means that the problem is that my whole pi is frozen when calling this command. does anyone know what's happening! How could such a simple command froze my whole pi!!
chmod +x x.py
, and run it from the command line, e.g../x.py
. Take note of any errors and correct.