I'm new to crontab and would like to run the following script from /etc/crontab
:
0 15 * * * root bash-c 'for i in /home/dell/Downloads/*.{pdf,docx,png,jpg,PDF,DOCX}; do shred -zvu "$i" -n20; done'
I have tried with and without bash-c
option, yet the script doesn't run.
My objective is:
- Get this script running from Crontab
- Get this script running on startup
Help is appreciated.
Best Answer
You're missing a space after the command
bash
and the argument-c
.This should work:
Some additional hints:
crontab
as userroot
if you don't need to./etc/crontab
file. Don't edit crontab files directly, rather usecrontab -e
command orsudo crontab -e
for commands which needroot
rights. Note, that you don't put theuser
field in the "other"crontab
files.If you have more than one command you can use
bash -c
as you do, but I'd rather put the commands in a script and execute this from crontab.To run a script on startup, you can use
@reboot
instead of0 15 * * *
.