1

I'm wanting schedule the execution python script at 08:00 AM, 18:00 PM and 22:00 PM. Checking the Crontab documentation, I think that the command would be

0 8,18,22 * * * /home/test/script.py

Now to create this task, Do I need to use crontab -e and last line add the command above?

1 Answers1

1

Looks correct to me.

Yes, you can open the task list by use of crontab -e. But you need to make sure, permissions are correct. If the script needs root access, you can't run it as user.

Also, just editing the task list alone won't do the trick. You need to make sure, some daemon like cronie is active and running to execute the tasks.

You can check, if cronie is active by use of:

systemctl status cronie

It might ask for permission or you might have to use sudo.

3 possible outcomes. Cronie might be active, inactive or not even installed. Last one should be fairly self-explanatory. You need to install cronie (apt-get install cronie).

systemctl start cronie.service

would start it temporarily. Usually that works fine and needs no settings. You can check the status again.

To make sure it's active after reboot and always, you need to ...

systemctl enable cronie.service

Just to have mentioned it, as a helper: if you are not sure about anything about this, you can always use some dummy script for testing. Just let it for example echo a timestamp into a file and see if it works.

Neobie
  • 151