Cronjob
Schedule commands to run on a repeating schedule using user's crontab file.
Cronjobların set olunması üçün cronie
paketinə ehtiyac var. Həmin paketi tapmaq üçün:
sudo yum whatprovides cronie
sudo yum install cronie-noanacron.x86_64 -y
check if crond service is enabled:
systemctl enable crond.service --now
systemctl status crond.service
display helpful info about crontab:
cat /etc/crontab
Task 1:
Set cronjob for user natasha to do /bin/echo
hiya at 14:23.
Solution:
crontab -eu natasha
23 14 * * * /bin/echo hiya
# test if cronjob is created
crontab -lu natasha
Task 2:
The user natasha must configure a cron job that runs daily at 14:23 local time and also the same cron job will run after every 2 minutes and executes.
Solution:
crontab -eu natasha
23 14 * * * /bin/echo hello # add the line to the file
*/2 * * * * /bin/echo hello # every 2 minutes
systemctl restart crond.service
systemctl enable crond.service
crontab -lu natasha
tail -f /var/log/cron
Task 3:
Configure a task: plan to run echo "file" command at 14:23 every day.
Solution:
crontab -eu natasha
23 14 * * * /bin/echo "file"
crontab -lu natasha
Last updated
Was this helpful?