Hi,
How do I set up a new cron job? Can I just edit crontab in /etc and add whatever I need (I want to add a weekly job to run the gravity.sh script for pihole)? It seems to work slightly different than in wheezy and before I break anything ...
Thanks
Cron job
Re: Cron job
Hi,Godisard wrote:Hi,
How do I set up a new cron job? Can I just edit crontab in /etc and add whatever I need (I want to add a weekly job to run the gravity.sh script for pihole)? It seems to work slightly different than in wheezy and before I break anything ...
Thanks
You can setup a simple weekly cron job for this. Please see below for a guide and example on how to set this up:
Create and edit your weekly cron job:
Code: Select all
nano /etc/cron.weekly/my_cron_job
Code: Select all
#!/bin/bash
#Run Gravity
/usr/local/bin/gravity.sh
#Restart dnsmasq
service dnsmasq restart
Code: Select all
chmod +x /etc/cron.weekly/my_cron_job
Code: Select all
/etc/cron.weekly/my_cron_job
If you find our project or support useful, then we’d really appreciate it if you’d consider contributing to the project however you can.
Donating is the easiest – you can use PayPal or become a DietPi patron.
Donating is the easiest – you can use PayPal or become a DietPi patron.
Re: Cron job
i know its super old but still first entry on google search
i did everything like Fourdee said.
the test worked as well. but the cron job is not executed :/
did anything change?

i did everything like Fourdee said.
the test worked as well. but the cron job is not executed :/
did anything change?
Re: Cron job
Hi,
many thanks for your report.
pls can you past the following command
just replace cron.weekly with the cron folder you used.
many thanks for your report.
pls can you past the following command
Code: Select all
ls -l /etc/cron.weekly
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
Re: Cron job
i will try it later today.
just for the learning curve: what is ls -l doing?
just for the learning curve: what is ls -l doing?
Re: Cron job
ls is going to show the content of a directory
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
Re: Cron job
-rwxr-xr-x 1 root root 1478 Mai 28 2019 apt-compat
-rwxr-xr-x 1 root root 1621 Jan 19 19:54 dietpi
-rwxr-xr-x 1 root root 1187 Apr 19 2019 dpkg
-rwxr-xr-x 1 root root 96 Jan 20 20:56 my_job
-rwxr-xr-x 1 root root 249 Sep 27 2017 passwd
-rwxr-xr-x 1 root root 1621 Jan 19 19:54 dietpi
-rwxr-xr-x 1 root root 1187 Apr 19 2019 dpkg
-rwxr-xr-x 1 root root 96 Jan 20 20:56 my_job
-rwxr-xr-x 1 root root 249 Sep 27 2017 passwd
Re: Cron job
Are you able to show the content of your script?
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
Re: Cron job
the script is huge.
if i run /etc/cron.daily/my_job
it works without problems, does cron have logs somewhere?
if i run /etc/cron.daily/my_job
it works without problems, does cron have logs somewhere?