# Schedule Python script

**URL:** <https://discuss.python.org/t/schedule-python-script/51410>\
**Category:** Python Help\
**Created:** [April 19, 2024, 5:08pm UTC](https://discuss.python.org/t/schedule-python-script/51410 "2024-04-19T17:08:20Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Parul255](https://avatars.discourse-cdn.com/v4/letter/p/53a042/32.png) [@Parul255](https://discuss.python.org/u/Parul255)\
**Post date:** [April 19, 2024, 5:08pm UTC](https://discuss.python.org/t/schedule-python-script/51410/1 "2024-04-19T17:08:20Z")

</div>

Hi,

I need to schedule my python script so that it runs daily even if user is logged in or not.  
I have tried Task scheduler but with that i can schedule scripts only when user is logged. For user not logged in, It is not working. Since i don’t have access to log on as batch in task scheduler.  
Is there any other way through which i can schedule my scripts and it gets run on a daily basis without logging to the system??

---

<div class="post-metadata">

**Author:** ![MegaIng](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/megaing/32/16162_2.png) [@MegaIng](https://discuss.python.org/u/MegaIng)\
**Post date:** [April 19, 2024, 6:29pm UTC](https://discuss.python.org/t/schedule-python-script/51410/2 "2024-04-19T18:29:14Z")

</div>

Generally, no, a user that isn’t logged in can’t run anything on the system. If you have access to the admin account (or a different always-active account with enough permissions) on that system, it can schedule stuff and run it as other users if that is really required.

---

<div class="post-metadata">

**Author:** ![moosemaimer](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/moosemaimer/32/15091_2.png) [@moosemaimer](https://discuss.python.org/u/moosemaimer)\
**Post date:** [April 22, 2024, 5:29pm UTC](https://discuss.python.org/t/schedule-python-script/51410/3 "2024-04-22T17:29:33Z")

</div>

You said Task Scheduler, so this is Windows, yes? Did you try setting the option for “Run task whether user is logged in or not”?

 ![](https://us1.discourse-cdn.com/flex002/uploads/python1/original/3X/c/d/cde2429f6348f4730ebb31f63b5818e36aa76c21.png)

You should enable the history, so if it doesn’t run like you expect it should, then it might tell you why.

![](https://us1.discourse-cdn.com/flex002/uploads/python1/original/3X/f/3/f3bd13b707e08ff158e88c6aad5cc5e3c44ab5a3.jpeg)

---

<div class="post-metadata">

**Author:** ![Parul255](https://avatars.discourse-cdn.com/v4/letter/p/53a042/32.png) [@Parul255](https://discuss.python.org/u/Parul255)\
**Post date:** [April 23, 2024, 7:18am UTC](https://discuss.python.org/t/schedule-python-script/51410/4 "2024-04-23T07:18:06Z")

</div>

Hi,

Thank you for your response but I tried this method already but When i select run whether user logged in or not it shows that i don’t have access as i am not admin. So if you know which access admin needs to grant to user to run this option or if their is any other method.

---

<div class="post-metadata">

**Author:** ![Parul255](https://avatars.discourse-cdn.com/v4/letter/p/53a042/32.png) [@Parul255](https://discuss.python.org/u/Parul255)\
**Post date:** [April 23, 2024, 7:20am UTC](https://discuss.python.org/t/schedule-python-script/51410/5 "2024-04-23T07:20:22Z")

</div>

Hi,

Thank you for your response but do you know the access that i need from admin to run it so i ask them to grant me that access.  
Or if their is any other method apart from Task scheduler?

---

<div class="post-metadata">

**Author:** ![c-rob](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/c-rob/32/17261_2.png) [@c-rob](https://discuss.python.org/u/c-rob)\
**Post date:** [April 23, 2024, 10:08am UTC](https://discuss.python.org/t/schedule-python-script/51410/6 "2024-04-23T10:08:12Z")

</div>

Please mention your OS in every question so we can better help you.

Cron does this on Linux systems, but when running a program via cron there is no environment for the program, no path, nothing. So you have to run a csh file which sets up the path and anything in the environment you need, and the csh file then runs the python program.

Each user can have their own cron jobs but so does the admin user. I just ran my jobs as the admin user to avoid permission problems as our machine was not on the internet but was on our private network.

I’m rusty in `csh` but here’s the general idea. Specify paths to everything. Let’s call this csh file `crondaily` and put it in the same dir as the python program you wrote.

```python
path=foo;bar;blah
/path/to/python/py /home/me/testprogs/program/program.py arg1 arg2

```

In the crontab file you would call `/fullpath/to/crondaily`.

1. I used Ubuntu. I only used the CLI not GUIs.
2. To edit crontab files do `crontab -e`.
3. To list the contents of your own crontab file do `crontab -l`.
