Finding Cronjobs created for 1 and 5 min
How to check the user cronjobs who created 1 min or 5 min on the server
i had an script which detect 1 min cron jobs please someone help me to find out the cronjob created 5 min
#!/bin/bash
ls -1 /var/spool/cron/| grep -v '^root'|while read u;
do
cat /var/spool/cron/${u}|\
awk '{print $1":"$2":"$3":"$4":"$5":"$NF}'|\
while read entry;
do
mn=$(echo ${entry}|awk -F':' '{print $1}');
if [[ ${mn} == "*" || ${mn} =~ "\*\/[0-5]$" ]];
then
echo "Minutely script found -> ${u} {$entry}";
fi;
done;
done;
-
Hey there! If I'm reading that script properly, it looks like this will already do this for you. That script is already detecting any cron that runs in 1, 2, 3, 4, or 5 minute intervals. We can see this from the following lines: mn=$(echo ${entry}|awk -F':' '{print $1}'); That pulls the first column, which is the time. And then this: if [[ ${mn} == "*" || ${mn} =~ "\*\/[0-5]$" ]]; Which gives you output if there is anything with the numbers 1 through 5 in that first column. So you should not need to do anything additional to get crons that are set for ever 5 minutes on the machine. 0 -
Hey there! If I'm reading that script properly, it looks like this will already do this for you. That script is already detecting any cron that runs in 1, 2, 3, 4, or 5 minute intervals. We can see this from the following lines: mn=$(echo ${entry}|awk -F':' '{print $1}'); That pulls the first column, which is the time. And then this: if [[ ${mn} == "*" || ${mn} =~ "\*\/[0-5]$" ]]; Which gives you output if there is anything with the numbers 1 through 5 in that first column. So you should not need to do anything additional to get crons that are set for ever 5 minutes on the machine.
If i change [0-15] will it show crons of 15 min ?0 -
That's correct. 0
Please sign in to leave a comment.
Comments
3 comments