Ubuntu 18.04 Cron job not running [duplicate]
This question already has an answer here:
Unable to execute command in cron
2 answers
I want to delete files from a folder that is created from another process with the 2019-02-21
format.
# Clear every 6 hours, 5 minutes
*/5 */6 * * * find /data/ding/dong/$(date '+%Y-%m-%d') -type f -exec rm -f {} ;
Update
Actually $(date
was not working with cronjob. see the answer for solution.
server 18.04 cron
marked as duplicate by steeldriver, karel, WinEunuuchs2Unix, Eric Carvalho, Charles Green Feb 23 at 17:22
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |
This question already has an answer here:
Unable to execute command in cron
2 answers
I want to delete files from a folder that is created from another process with the 2019-02-21
format.
# Clear every 6 hours, 5 minutes
*/5 */6 * * * find /data/ding/dong/$(date '+%Y-%m-%d') -type f -exec rm -f {} ;
Update
Actually $(date
was not working with cronjob. see the answer for solution.
server 18.04 cron
marked as duplicate by steeldriver, karel, WinEunuuchs2Unix, Eric Carvalho, Charles Green Feb 23 at 17:22
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
1
It is best to call a script from cron. The script in turn can calldate
command and other commands.
– WinEunuuchs2Unix
Feb 22 at 11:33
add a comment |
This question already has an answer here:
Unable to execute command in cron
2 answers
I want to delete files from a folder that is created from another process with the 2019-02-21
format.
# Clear every 6 hours, 5 minutes
*/5 */6 * * * find /data/ding/dong/$(date '+%Y-%m-%d') -type f -exec rm -f {} ;
Update
Actually $(date
was not working with cronjob. see the answer for solution.
server 18.04 cron
This question already has an answer here:
Unable to execute command in cron
2 answers
I want to delete files from a folder that is created from another process with the 2019-02-21
format.
# Clear every 6 hours, 5 minutes
*/5 */6 * * * find /data/ding/dong/$(date '+%Y-%m-%d') -type f -exec rm -f {} ;
Update
Actually $(date
was not working with cronjob. see the answer for solution.
This question already has an answer here:
Unable to execute command in cron
2 answers
server 18.04 cron
server 18.04 cron
edited Feb 22 at 12:04
AZ_
asked Feb 21 at 11:25
AZ_AZ_
1166
1166
marked as duplicate by steeldriver, karel, WinEunuuchs2Unix, Eric Carvalho, Charles Green Feb 23 at 17:22
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
marked as duplicate by steeldriver, karel, WinEunuuchs2Unix, Eric Carvalho, Charles Green Feb 23 at 17:22
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
1
It is best to call a script from cron. The script in turn can calldate
command and other commands.
– WinEunuuchs2Unix
Feb 22 at 11:33
add a comment |
1
It is best to call a script from cron. The script in turn can calldate
command and other commands.
– WinEunuuchs2Unix
Feb 22 at 11:33
1
1
It is best to call a script from cron. The script in turn can call
date
command and other commands.– WinEunuuchs2Unix
Feb 22 at 11:33
It is best to call a script from cron. The script in turn can call
date
command and other commands.– WinEunuuchs2Unix
Feb 22 at 11:33
add a comment |
2 Answers
2
active
oldest
votes
Check if cron is running, may be you have it disabled/not installed:
leonid@Desktop:~$ /etc/init.d/cron status
● cron.service - Regular background program processing daemon
Loaded: loaded (/lib/systemd/system/cron.service; enabled; vendor preset: enabled)
Active: active (running)
And redirect error output of commands to some log file, to check what's wrong.
add a comment |
Thanks WinEunuuchs2Unix for the hint.
Create an script in your home directory with chmod +x
executable access I have done chmod 0755
Go to /etc/crontab
and enter the following line
*/5 */6 * * * root /home/john/{your script name}.sh >> /var/log/cronErrLog.txt 2>&1
and it will run every 6 hours 5 minutes
You can put this into your {your script name}.sh
find /data/ding/dong/$(date '+%Y-%m-%d') -type f -exec rm -f {} ;
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
Check if cron is running, may be you have it disabled/not installed:
leonid@Desktop:~$ /etc/init.d/cron status
● cron.service - Regular background program processing daemon
Loaded: loaded (/lib/systemd/system/cron.service; enabled; vendor preset: enabled)
Active: active (running)
And redirect error output of commands to some log file, to check what's wrong.
add a comment |
Check if cron is running, may be you have it disabled/not installed:
leonid@Desktop:~$ /etc/init.d/cron status
● cron.service - Regular background program processing daemon
Loaded: loaded (/lib/systemd/system/cron.service; enabled; vendor preset: enabled)
Active: active (running)
And redirect error output of commands to some log file, to check what's wrong.
add a comment |
Check if cron is running, may be you have it disabled/not installed:
leonid@Desktop:~$ /etc/init.d/cron status
● cron.service - Regular background program processing daemon
Loaded: loaded (/lib/systemd/system/cron.service; enabled; vendor preset: enabled)
Active: active (running)
And redirect error output of commands to some log file, to check what's wrong.
Check if cron is running, may be you have it disabled/not installed:
leonid@Desktop:~$ /etc/init.d/cron status
● cron.service - Regular background program processing daemon
Loaded: loaded (/lib/systemd/system/cron.service; enabled; vendor preset: enabled)
Active: active (running)
And redirect error output of commands to some log file, to check what's wrong.
answered Feb 21 at 12:22
LeonidMewLeonidMew
659619
659619
add a comment |
add a comment |
Thanks WinEunuuchs2Unix for the hint.
Create an script in your home directory with chmod +x
executable access I have done chmod 0755
Go to /etc/crontab
and enter the following line
*/5 */6 * * * root /home/john/{your script name}.sh >> /var/log/cronErrLog.txt 2>&1
and it will run every 6 hours 5 minutes
You can put this into your {your script name}.sh
find /data/ding/dong/$(date '+%Y-%m-%d') -type f -exec rm -f {} ;
add a comment |
Thanks WinEunuuchs2Unix for the hint.
Create an script in your home directory with chmod +x
executable access I have done chmod 0755
Go to /etc/crontab
and enter the following line
*/5 */6 * * * root /home/john/{your script name}.sh >> /var/log/cronErrLog.txt 2>&1
and it will run every 6 hours 5 minutes
You can put this into your {your script name}.sh
find /data/ding/dong/$(date '+%Y-%m-%d') -type f -exec rm -f {} ;
add a comment |
Thanks WinEunuuchs2Unix for the hint.
Create an script in your home directory with chmod +x
executable access I have done chmod 0755
Go to /etc/crontab
and enter the following line
*/5 */6 * * * root /home/john/{your script name}.sh >> /var/log/cronErrLog.txt 2>&1
and it will run every 6 hours 5 minutes
You can put this into your {your script name}.sh
find /data/ding/dong/$(date '+%Y-%m-%d') -type f -exec rm -f {} ;
Thanks WinEunuuchs2Unix for the hint.
Create an script in your home directory with chmod +x
executable access I have done chmod 0755
Go to /etc/crontab
and enter the following line
*/5 */6 * * * root /home/john/{your script name}.sh >> /var/log/cronErrLog.txt 2>&1
and it will run every 6 hours 5 minutes
You can put this into your {your script name}.sh
find /data/ding/dong/$(date '+%Y-%m-%d') -type f -exec rm -f {} ;
edited Feb 22 at 12:04
answered Feb 22 at 11:55
AZ_AZ_
1166
1166
add a comment |
add a comment |
1
It is best to call a script from cron. The script in turn can call
date
command and other commands.– WinEunuuchs2Unix
Feb 22 at 11:33