1751898 Members
5849 Online
108783 Solutions
New Discussion юеВ

Re: cron issue

 
newunix
Frequent Advisor

cron issue

after setting cron as
cat samplecron

0,10,20,30,40,50 * * * * /usr/bin/bdf >> /tmp/bdf.log

i can get the output but my problem is

if i schedule new cron job and i execute crontab filename ,, previous running cron job get removed.

how can i preserve the previous running cron jobs.
15 REPLIES 15
Elmar P. Kolkman
Honored Contributor

Re: cron issue

You can do that by adding the entries together. With the crontab -l command you can view your current jobs.

Easiest way:
$ crontab -l >oldcron.txt
$ cat oldcron.txt newcron.txt | crontab -

Every problem has at least one solution. Only some solutions are harder to find.
Dennis Handly
Acclaimed Contributor

Re: cron issue

>how can I preserve the previous running cron jobs.

Your crontab entry must contain ALL of your jobs. If you want to add more, you can use "crontab -e".
Hakki Aydin Ucar
Honored Contributor

Re: cron issue

Hi,
How did you enter new cron jab ?
crontab -e ??

You mean after save the crontab, you cannot see your previous job anymore inside cron with the command:
# crontab -l ??
newunix
Frequent Advisor

Re: cron issue

hi hakki

when i created first cron job i used vi samplecron

then i executed crontab firstcronjob

for adding second cron job for the same user again i used vi editor and i executed
crontab secondcronjob

after that i listed jobs with crontab -l ,, firstcronjob was missing
Dennis Handly
Acclaimed Contributor

Re: cron issue

>and I executed crontab secondcronjob

That's what Hakki suspected. You can't do that. You must put ALL of your user's crontab entries in one "logical" file. The one you pass to crontab(1).
Steven Schweda
Honored Contributor

Re: cron issue

> cron issue

Is that anything like a _problem_?

> [...] and i executed
> crontab secondcronjob

man crontab

Not knowing your HP-UX version, I can't quote
the exact text, but I'd guess that it says
something like:

Create or replace your crontab file by
copying the specified file, [...]

Nothing there about "appending the specified
file".


> crontab -e ??

You might consider using that option.
newunix
Frequent Advisor

Re: cron issue

so if i want to add another cron job for the same user ,,,

i have to use crontab -e and add the second job.

after that do i need to execute
crontab secondjob
newunix
Frequent Advisor

Re: cron issue

can i have an example for particular user having one job already and to add another cron job.
Dennis Handly
Acclaimed Contributor

Re: cron issue

>I have to use crontab -e and add the second job. after that do i need to execute: crontab secondjob

No, you keep using "crontab -e". Or you can use "crontab -l" and put that in a file and resubmit that file with your changes.

>can I have an example for particular user having one job already and to add another cron job.

Use "crontab -e" to edit your existing crontab entry. Then add as many as you want.

Note: One problem with "crontab -e" is that you don't have a backup if your disks crash and it isn't in a source management system.

So you could just start with a file and just add to it, then use "crontab file" each time.