3

I have a python script, and I wish to run it once and only once everyday. I did some research on the crontab command, and it seems to do so, but at a fixed time each day. The issue is that my computer won't be on all day and a specific time for running it is just not possible. What can I do?

Could a log file help? I was thinking of doing a crontab every 5 minutes or so and scanning a log file to see any runs for the day.

1
  • 2
    Use anacron, and it'll run your scheduled tasks when you do have your computer switched on. Commented Jul 4, 2015 at 18:19

4 Answers 4

7

Install anacron, a cron scheduler that'll handle tasks that run at most once a day when your computer is powered on.

From the WikiPedia page:

anacron is a computer program that performs periodic command scheduling which is traditionally done by cron, but without assuming that the system is running continuously. Thus, it can be used to control the execution of daily, weekly, and monthly jobs (or anything with a period of n days) on systems that don't run 24 hours a day.

Sign up to request clarification or add additional context in comments.

Comments

0

Anacron will do it

or

at

Anacron is probably your best choice.

Comments

0

@reboot can be used in crontab entry to run script once when system is rebooted.

e.g.

[test@host1 ~]$crontab -l @reboot /home/test/bootScript.sh 

1 Comment

This also means that you then have to reboot the system daily. You cannot leave it on over the weekend once in a while.
0

You can run it in a server which is on all day and everyday. You can get a free server hosting on sites like this: https://www.5gbfree.com/

This way, if you have sick days where you won't even think to open your laptop, the cron jobis still running in the server anyway.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.