PDA

View Full Version : automatic upgrade_export



Pussala@gmail.com
04-30-08, 07:06 AM
I want automatic upgrade_export.


[Expert@MNGFW01]# crontab -e:

50 12 * * * cd /opt/CPsuite-R62/fw1/bin/upgrade_tools
51 12 * * * echo | ./upgrade_export appoggio
25 13 * * * oggi=`date`
26 13 * * * mv appoggio.tgz.tar $oggi
27 13 * * * scp $oggi root@172.28.121.16:/data/backup_2008

[Expert@MNGFW01]# less /var/log/cron

Apr 30 12:50:00 MNGFW01 CROND[22798]: (root) CMD (cd /opt/CPsuite-R62/
fw1/bin/upgrade_tools)
Apr 30 12:51:00 MNGFW01 CROND[22806]: (root) CMD (echo | ./
upgrade_export appoggio)
Apr 30 12:52:24 MNGFW01 crontab[22820]: (root) LIST (root)
Apr 30 12:53:19 MNGFW01 crontab[22821]: (root) LIST (root)
Apr 30 12:54:14 MNGFW01 crontab[22827]: (root) BEGIN EDIT (root)
Apr 30 12:54:26 MNGFW01 crontab[22827]: (root) END EDIT (root)
Apr 30 13:25:00 MNGFW01 CROND[22966]: (root) CMD (oggi=`date`)
Apr 30 13:25:54 MNGFW01 crontab[22972]: (root) LIST (root)
Apr 30 13:26:00 MNGFW01 CROND[22974]: (root) CMD (mv appoggio.tgz.tar
$oggi)
Apr 30 13:27:00 MNGFW01 CROND[22980]: (root) CMD (scp $oggi
root@172.28.121.16:/data/backup_2008 )
Apr 30 13:28:30 MNGFW01 crontab[22988]: (root) LIST (root)
Apr 30 13:29:30 MNGFW01 crontab[22997]: (root) BEGIN EDIT (root)
Apr 30 13:30:05 MNGFW01 crontab[22997]: (root) END EDIT (root)

If I run commands without crontab all ok!
With crontab run upgrade_export but does not create anything!

What happens?
Where is the error?

Moe Trin
04-30-08, 02:58 PM
On Wed, 30 Apr 2008, in the Usenet newsgroup comp.security.firewalls, in article
<a1cd45b8-f83e-438a-95cb-dfc71573cc5c@y38g2000hsy.googlegroups.com>,
Pussala@gmail.com wrote:

NOTE: Posting from groups.google.com (or some web-forums) dramatically
reduces the chance of your post being seen. Find a real news server.

>I want automatic upgrade_export.

And what does this have to do with firewalls?

>[Expert@MNGFW01]# crontab -e:
>
>50 12 * * * cd /opt/CPsuite-R62/fw1/bin/upgrade_tools
>51 12 * * * echo | ./upgrade_export appoggio
>25 13 * * * oggi=`date`
>26 13 * * * mv appoggio.tgz.tar $oggi
>27 13 * * * scp $oggi root@172.28.121.16:/data/backup_2008

1. uname -a
2. which cron
3. man cron
4. man crontab

Then add the following lines to this crontab:

52 12 * * * * set > /tmp/cron.environment.12.52
26 13 * * * * set > /tmp/cron.environment.13.26

and finally, run the command 'set > /tmp/my.environment

and then compare those three files in /tmp. You'll find that the
environment is quite different, and commands that you run in a cron
child process have no effect on _other_ child processes that may be
spawned by the parent. As you've decided to do this in cron, create
a single job that runs at a chosen time, such as

55 12 * * * run.this.silly.script

where 'run.this.silly.script' contains the actual commands

#!/bin/sh
cd /opt/CPsuite-R62/fw1/bin/upgrade_tools
echo | ./upgrade_export appoggio
oggi=`date`
mv appoggio.tgz.tar $oggi
scp $oggi root@172.28.121.16:/data/backup_2008

Incidentally, that is a rather interesting extension for a file 'tgz.tar'

For further help, try an appropriate UNIX newsgroup, or comp.unix.shell.
Do try to find a real news server first, as many people filter posts
from groups.google.com.

Old guy

rick@bcm.tmc.edu
05-01-08, 11:37 AM
On Apr 30, 2:58*pm, ibupro...@painkiller.example.tld (Moe Trin) wrote:
> On Wed, 30 Apr 2008, in the Usenet newsgroup comp.security.firewalls, in article
> <a1cd45b8-f83e-438a-95cb-dfc71573c...@y38g2000hsy.googlegroups.com>,
>
> Puss...@gmail.com wrote:
>
> NOTE: Posting from groups.google.com (or some web-forums) dramatically
> reduces the chance of your post being seen. *Find a real news server.
>
> >I want automatic upgrade_export.
>
> And what does this have to do with firewalls?

Because he is discussing an issue with Checkpoint upgrade_export
maybe.
I see he did go to www.cpug.org and asked the same question and got an
answer.

Moe Trin
05-02-08, 03:07 PM
On Thu, 1 May 2008, in the Usenet newsgroup comp.security.firewalls, in article
<9517d840-06b9-4ea9-bc2c-fd819941279b@25g2000hsx.googlegroups.com>,
rick@bcm.tmc.edu wrote:

NOTE: Posting from groups.google.com (or some web-forums) dramatically
reduces the chance of your post being seen. Find a real news server.

>ibupro...@painkiller.example.tld (Moe Trin) wrote:

>> Puss...@gmail.com wrote:

>>> I want automatic upgrade_export.
>>
>> And what does this have to do with firewalls?
>
>Because he is discussing an issue with Checkpoint upgrade_export
>maybe.

Barking at the wrong tree - his problem is a fundamental mis-understanding
of the UNIX 'cron' daemon, and has nothing to do with any firewall. His
post in this group continued:

If I run commands without crontab all ok!
With crontab run upgrade_export but does not create anything!

So there is nothing wrong with the commands (what ever they may be), but
they fail to run in his rather bizarre interpretation of what the manual
page says for 'crontab'. That's also why (after answering his question)
I suggested he look at an appropriate UNIX newsgroup, or comp.unix.shell.

>I see he did go to www.cpug.org and asked the same question and got an
>answer.

He posted from googlegroups, and (like many) I filter those posts off
in a number of the other newsgroups I try to scan daily, but I also
see that he posted to (at least) 'comp.os.linux.misc' and got an answer
similar to the one I provided - run all of the commands out of a single
script, rather than running five independent (and unrelated) commands
out of root's crontab.

Old guy

Pussala@gmail.com
05-05-08, 08:05 AM
On 2 Mag, 22:07, ibupro...@painkiller.example.tld (Moe Trin) wrote:
> On Thu, 1 May 2008, in the Usenet newsgroup comp.security.firewalls, in article
> <9517d840-06b9-4ea9-bc2c-fd8199412...@25g2000hsx.googlegroups.com>,
>
> r...@bcm.tmc.edu wrote:
>
> NOTE: Posting from groups.google.com (or some web-forums) dramatically
> reduces the chance of your post being seen. Find a real news server.
>
> >ibupro...@painkiller.example.tld (Moe Trin) wrote:
> >> Puss...@gmail.com wrote:
> >>> I want automatic upgrade_export.
>
> >> And what does this have to do with firewalls?
>
> >Because he is discussing an issue with Checkpoint upgrade_export
> >maybe.
>
> Barking at the wrong tree - his problem is a fundamental mis-understanding
> of the UNIX 'cron' daemon, and has nothing to do with any firewall. His
> post in this group continued:
>
> If I run commands without crontab all ok!
> With crontab run upgrade_export but does not create anything!
>
> So there is nothing wrong with the commands (what ever they may be), but
> they fail to run in his rather bizarre interpretation of what the manual
> page says for 'crontab'. That's also why (after answering his question)
> I suggested he look at an appropriate UNIX newsgroup, or comp.unix.shell.
>
> >I see he did go towww.cpug.organd asked the same question and got an
> >answer.
>
> He posted from googlegroups, and (like many) I filter those posts off
> in a number of the other newsgroups I try to scan daily, but I also
> see that he posted to (at least) 'comp.os.linux.misc' and got an answer
> similar to the one I provided - run all of the commands out of a single
> script, rather than running five independent (and unrelated) commands
> out of root's crontab.
>
> Old guy

I edit script for backup:

#!/bin/sh
.. /etc/profile.d/CP.sh
cd /var/CPbackup/backups
echo | backup -d --file /var/CPbackup/backups/
scp fw_export pluto@172.29.198.23:/data/backup
exit 0

Can I exec the backup command without me being asked "Are you sure you
want to proceed?"
The command "echo |" not work !!!

Thanks

Moe Trin
05-05-08, 03:03 PM
On Mon, 5 May 2008, in the Usenet newsgroup comp.security.firewalls, in article
<c36a495b-05aa-4d03-9862-55261ceae9e9@s50g2000hsb.googlegroups.com>,
Pussala@gmail.com wrote:

NOTE: Posting from groups.google.com (or some web-forums) dramatically
reduces the chance of your post being seen. Find a real news server.

>I edit script for backup:
>
>#!/bin/sh
>. /etc/profile.d/CP.sh
>cd /var/CPbackup/backups
>echo | backup -d --file /var/CPbackup/backups/
>scp fw_export pluto@172.29.198.23:/data/backup
>exit 0
>
>Can I exec the backup command without me being asked "Are you sure you
>want to proceed?"

You would have to check the manual page for the 'backup' command (which
is not a Linux or UNIX standard command) to see if it has an appropriate
option - I can't imagine why it needs to ask you to proceed. Could this
be a variable that is set in the /etc/profile.d/CP.sh file?

>The command "echo |" not work !!!

At least two problems. First, the 'backup' command has to display the
stupid question, but where does it do this? 'cron' has no standard
terminal, so it _may_ be trying to send the question via email to the
person running this crontab. A solution to that is to redirect stdout
to a file or device, such as /dev/null.

Second problem - the 'echo |' command is going to echo a carriage
return

[compton ~]$ echo | hexdump
0000000 000a
0000001
[compton ~]$

into the pipe, but is the backup program expecting input when invoked?
In your original post you indicated that things worked from the command
line, but not from cron. Does the 'echo |' work at the command line?
If it does, you might try

echo | backup -d --file /var/CPbackup/backups/ &>/tmp/somefile

to see if it's the lack of output device for cron that is causing the
problem.

Old guy