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.
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
The end!
Well, nothing more to add, I hope as always ... it has been useful.
Gentoo is you?
https://wiki.gentoo.org/wiki/Handbook:X86/Installation/Tools
I was looking forward to a tutorial on using cronie. At last I could find it. Thank you!! 😀
needless
https://wiki.archlinux.org/index.php/Systemd/Timers#As_a_cron_replacement
Timers, as the wiki explains well, are the alternative in systemd, it is not "Reuse Crontab in ArchLinux".
Wow I did not know "cronie" at last I can use crontab in archlinux, it is also in the chakralinux repos:]
Thank you!! 0 /
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!!
Oh right, my bad, I already correct it 🙂
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