elmuscovado
elmuscovado

Reputation: 114

Is there a way to leave python code running when the computer is shutdown?

I have a python script that checks the temperature every 24 hours, is there a way to leave it running if I shut the computer down/log off.

Upvotes: 1

Views: 15240

Answers (4)

John
John

Reputation: 43

You can take a look at the following pages http://www.wikihow.com/Automatically-Turn-on-a-Computer-at-a-Specified-Time

http://lifehacker.com/5831504/how-can-i-start-and-shut-down-my-computer-automatically-every-morning

Additionally once it turn on, you can perform a cronjob, for execute your python code by a console command >> python yourfile.py . What is the Windows version of cron?

Upvotes: 1

EJGannon
EJGannon

Reputation: 23

The best way to accomplish this is to have your program run on some type of server that your computer can connect to. A server could be anything from a raspberry pi to an old disused computer or a web server or cloud server. You would have to build a program that can be accessed from your computer, and depending on the server and you would access it in a lot of different ways depending the way you build your program and your server.

Doing things this way means your script will always be able to check the temperature because it will be running on a system that stays on.

Upvotes: 2

Will Schnicke
Will Schnicke

Reputation: 21

Scripts are unable to run while your computer is powered off. What operating system are you running? How are you collecting the temperature? It is hard to give much more help without this information.

One thing I might suggest is powering on the system remotely at a scheduled time, using another networked machine.

Upvotes: 0

Alan
Alan

Reputation: 3042

Shutdown - no.
Logoff - potentially, yes.

If you want to the script to automatically start when you turn the computer back on, then you can add the script to your startup folder (Windows) or schedule the script (Windows tasks, cron job, systemd timer).

If you really want a temperature tracker that is permanently available, you can use a low-power solution like the Raspberry Pi rather than leaving your pc on.

Upvotes: 2

Related Questions