1. /home/lvtest/test/test.py
from datetime import datetime now=datetime.now() f=open('test.log','a') f.write('%s '%now) f.close()
2. edit /etc/rc.local with adding codes below:
cd /home/lvtest/test
su lvtest -c "python /home/lvtest/test/test.py"
exit 0 # ? if it is necessary
3. Make your /etc/rc.local executable in case it is not already executable by
sudo chown root /etc/rc.local
sudo chmod 755 /etc/rc.local
4. Check everything works fine by executing
sudo /etc/rc.local start