top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

How to load a cronjob without crontab command?

+2 votes
413 views

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?

posted Jan 14, 2014 by Salil Agrawal

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

1 Answer

+1 vote
 
Best answer

the command which can take instruction from stdin and load as crontab is crontab - so you need to take the old crontab and append your command and load it as new crontab.

Try the following script -

newcmd="* * * * * /home/mycronjob.sh >/dev/null 2>&1"
(crontab -l; echo "$newcmd") | crontab -
answer Jan 14, 2014 by Luv Kumar
Similar Questions
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.

+6 votes

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

...