Reuse Crontab on ArchLinux Using Cronie

Those of us who like to have tasks scheduled on the PC, automate tasks and things like that, we know thoroughly cron and consequently, crontab.

It happens that in ArchLinux now things have changed, SystemD He is the almighty who knows everything, does everything and everyone depends on him ... so, what we did before was edit / etc / crontab, well, we won't be able to do it anymore 🙁

Now in ArchLinux we must install a package called crony, which will make it easier for us to automate tasks, schedule orders for the system to follow at a certain time.

archlinuxbylapapunk

Install and enable Cronie

The first thing will obviously be to install cronie, for this:

sudo pacman -S cronie

Then we must start it and enable it:

sudo systemctl start cronie sudo systemctl enable cronie

How to schedule a task with Cronie?

It is simple, by means of a command that we could also use before, it will allow us to edit the scheduled tasks of our user.

But first!!, those who are not familiar with vi I recommend that you declare to dwarf as its default editor in terminal:

echo "export EDITOR = nano" >> $ HOME / .bashrc export EDITOR = nano

To actually schedule a task we will use the command:

crontab -e

This will show us a text editor in terminal (nano if they did the above) blank, there we write what we put before, for example I will put that every 1 minute a file is created in my home called test:

* *   * * * touch /home/tu-usuario/prueba

For the change to take effect, that is, to take it into account, it is NOT necessary to restart the service, much less, everything is instantaneous.

How to use crontab?

If you don't know how to use crontab, what you should write, here are some articles that will be helpful:

For example, I want a script to be executed at 11AM, the line would be:

00 11   * * * cd /home/kzkggaara/Scripts/ && ./miscript.sh

IMPORTANT, they should not put the user in the file that is opened when they execute crontab -e, before in / etc / crontab they had to put the user who would execute the command, now with crontab -e it is no longer necessary.

The end!

Well, nothing more to add, I hope as always ... it has been useful.


8 comments, leave yours

Leave a Comment

Your email address will not be published. Required fields are marked with *

*

*

  1. Responsible for the data: Miguel Ángel Gatón
  2. Purpose of the data: Control SPAM, comment management.
  3. Legitimation: Your consent
  4. Communication of the data: The data will not be communicated to third parties except by legal obligation.
  5. Data storage: Database hosted by Occentus Networks (EU)
  6. Rights: At any time you can limit, recover and delete your information.

  1.   mat1986 said

    I was looking forward to a tutorial on using cronie. At last I could find it. Thank you!! 😀

    1.    mario said

      Timers, as the wiki explains well, are the alternative in systemd, it is not "Reuse Crontab in ArchLinux".

  2.   algave said

    Wow I did not know "cronie" at last I can use crontab in archlinux, it is also in the chakralinux repos:]

    Thank you!! 0 /

  3.   Eduardo said

    In the posted example the script would run every day at 00:11 am and not at 11:00 am. Remember that the first parameter is the minutes and the second the hour.

    Regards!!

    1.    KZKG ^ Gaara said

      Oh right, my bad, I already correct it 🙂

  4.   willarmand said

    I do not know if this would give me the same problems as cron, for me it is impossible to use rtcwake with cron, it just does not work for me, I have looked everywhere to schedule a task of that command and it simply does not work, for example this works in the terminal:
    sudo rtcwake -m standby -t $ (date +% s -d '10:31')
    but when putting it with the cron it only says that it is installing it but it cannot execute it.
    Does anyone know how to fix it, or can't it?
    regards