this is my first time writing script for cron job.
I wrote my code in shell, (which it works) and I’m trying to set it up for cron.
So here is my question. How do I set up the cron? Am I suppose to write
10 * * * * /home/workstation/deleter.sh (I want it to run every 10min)
right underneath #!/bin/sh? How would I execute it? (deleter.sh has permission via chmod)
man 1 crontab returns “No entry for crontab in section 1 of the manual”
I’m really lost and confused right now. If someone know how to set up cron please tell me!!
Thanks in advance
#!/bin/sh
counter=0
logloc=/home/ServerLogs
backup=/home/test
## Reads the location of the file systems that needs to be investigated from location.txt
## and save it into an array
while read -r line; do
Unix_Array[${counter}]=$line;
let counter=counter+1;
done < location.txt
## Reads Email recipients and save it into an array
More code continues from here......
To setup the cron, you can do one of two (main) things. The first would be to place the specified line in
/etc/crontab. The second would be to runcrontab -eand place the line in there. I would recommend to usecrontab -eso the cron will execute as your own user account.If the full path to the script is
/home/workstation/deleter.shand it does have execute-privileges, as you specified – your current line will have it execute 10-minutes past the hour, every hour. To get it to execute every 10 minutes, you’ll have to use*/10, like this: