How to run python automated scripts when your pc is off

Hi, Recently I Have Learned To Automate Things And Tasks With Python To Make My Tasks Easier… But The Problem Is I Cannot Keep My PC On The Whole Day And I Become To Know That Python Scripts Cannot Run When Your PC Is Off…

So, Please Suggest And Best, Free And Safe Solution Of This Problem Where I Can Run My My Python Scripts When My PC Is Completely Off…

You Can Provide Some Useful Links To Solve This Problem…

Thanks In Advance… :blush::blush::blush:

If your PC is off, it is off, and it cannot run anything.

You have two choices.

  1. Leave your computer on, and run the scripts on your computer.

  2. Turn your computer off, and run the scripts on a different computer, which is on.

1 Like

I agree with Steven, though will suggest there is probably some cron-like tool out there that will “catch up” on missed events when the computer is rebooted. That still adheres to Steven’s operational definition of what computers can (and can’t) do when turned off. :wink:

Tracking down such a tool is left as an exercise for the OP.

On Linux systems I believe that tool is anacron.

I don’t know what the Windows equivalent would be.

Task Scheduler should be able to do it on Windows, and you can also have it wake the system from sleep. On on macOS systems, there’s some sort of hardware watchdog that can not only wake the system from sleep to run a task at a scheduled time, but actually boot it from being shut down, and then shut it down again. To do that on Windows or Linux you’d probably need wake on LAN or an external relay (which I’ve done for our RPis deployed in the field).

Yes, Apple hardware often turns on and off from software, which means that when you think the device is powered down, it might not be. That has dangerous implications:

https://www.schneier.com/blog/archives/2022/01/faking-an-iphone-reboot.html

1 Like