Schedule Python script

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??

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.

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”?

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

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.

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?

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.

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.