top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Cronjob in Linux

+6 votes
514 views

I want to have two cronjob as per following routine.
1. First job I want to start at the start of every month.
2. Second job I want at every 4 hours.

Any suggestions

posted Sep 22, 2013 by Salil Agrawal

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

+3 votes

crontab to run after reboot

@reboot  scriptname.sh 

every 4hrs

00 */04 * * * scriptname.sh 
answer Sep 22, 2013 by Rajabhaskar
Thanks a lot, what about if I want to run at the 1st day of every month
every 1st of the month
00 00 1 * * scriptname.sh
Similar Questions
+2 votes

In my linux system I want to start a cronjob but don't want to enter the enter the cronjob using 'crontab -e' rather want to enter without using 'crontab -e' may be via a script.

Any suggestion on how to achieve this?

0 votes

How do I execute certain shell script at a specific intervals in Linux using cron job?
Please provide examples using different time periods.

–1 vote

from man crontab:

Step values can be used in conjunction with ranges. Following a range with / specifies skips of the number's value through the range. For example 0-23/2 can be used in the hours field to specify command execution every other hour (the alternative in the V7 standard is 0,2,4,6,8,10,12,14,16,18,20,22). Steps are also permitted after an asterisk, so if you want to say every two hours, just use */2

As an example, I see:

~# 
~# cat /etc/cron.d/leafnode 
# Cron entries for Leafnode.
# Run /etc/news/leafnode/do-fetch-news every hour.
8 * * * * news if [ -x /etc/news/leafnode/do-fetch-news ]; then /etc/news/leafnode/do-fetch-news; fi

now, every, let's say, two hours I want to run "killall fetchnews" because it has a tendency to stall. Would that look like:

#cron to kill defunct fetchnews
* */2 * * * killall fetchnews

(leaving out the logic of looking for a zombie process (if that's correct terminology))

0 votes

One of our script need run on first Saturday every month. We have following setup on cron job but it run every Saturday.

15 04 1-7 * 6 /xxx/monthlybk.sh

Any one know how to fix it?

...