I want to set cronjob on Raspberry Pi 3, initiated by python subprocess, but I am not sure how to code pressing keys ctrl
+ x
,then y
,and then enter
to save it. I am using nano as a text editor, and the below is my code so far.
p = Popen(["crontab -e"], stdin=PIPE, stdout=PIPE, shell=True)
p.stdin.write("@reboot python test.py")
you can do it with the following bash command without using vi editor:
(crontab -l ; echo "0 4 * * * myscript")| crontab -