Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1l7FEZ-0001Em-F7 for pgsql-admin@arkaria.postgresql.org; Wed, 03 Feb 2021 10:18:03 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1l7FEY-0001yI-9y for pgsql-admin@arkaria.postgresql.org; Wed, 03 Feb 2021 10:18:02 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1l7FEX-0001yB-Ve for pgsql-admin@lists.postgresql.org; Wed, 03 Feb 2021 10:18:02 +0000 Received: from mail-ot1-x333.google.com ([2607:f8b0:4864:20::333]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1l7FEW-0002O0-5H for pgsql-admin@lists.postgresql.org; Wed, 03 Feb 2021 10:18:01 +0000 Received: by mail-ot1-x333.google.com with SMTP id y11so1263350otq.1 for ; Wed, 03 Feb 2021 02:18:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language; bh=sqGP+X/IqpixQdsat9MASwTDPTq7Qzw1rmfw77CUvkc=; b=SSeKbeKvppDRaf4okJHvMGt2mpG3pD1Z8CgfRnpiAAMqwc3TEtnx952MxFllOj6kuv tw1y8/WZ/1UTqvoD7PvAd/L9JNxDbON6z05I/HfepyvB/K+iRGObq6CNbiIDVkT7XRGO /n8O9sF3gHxNdy5vN4V1kTIzq2PzB3jEW33ibSGwPJ9HO70K6ztSJempV6l/c85pRGkS rELySfKu/zcmamvG+f2K26uo6ukPyGOqkiYtVwPQXggotAMAHZDEvKoP8ALq3twpkoij rXxhKe/XDKZ80LaVFAA3qw+s8I5x64wTOw6+ur4DCfTG+ezztxb/XShqzS7rfww6BxM9 W1Mg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language; bh=sqGP+X/IqpixQdsat9MASwTDPTq7Qzw1rmfw77CUvkc=; b=th8nZrwHNZgiSTTdiv4UzJE7p0xMCrazw6VLsJI/mqgR+/TlEOfWatyCpvCCbbPvLN Kv+LnGWpjRpEufosl/T2kpuVv5JjJiLsWt711pPYEwF50kqkF018Sxn8BXe0U2addn1C Lv3BDzZa9PvE0/19QG6kE6cW7eooVzlXEMGUGqB2BJTr2HY9rPR/wsSlcYTDEDbCZ7OH YxpZS8+0wfk6Kvco95UuQaxpSvUQ4St1zwc4hjspDzW1ZZJum0Epu9G/d5rSWlrHsTaM nqaRPUkk89fA7fqNfVG9ewfr3dAqTczUtBk3hsMw7L2Cwy62rIDt0nSoDvhDIC8CUm50 gNfA== X-Gm-Message-State: AOAM533I8IZdWjezeMM8r1IX7BwV5c7sV4D7EQGK5bD7Ppn6WgpY29QU GhBeJ9fkr254Ug5xeUR2E1BlsZKsIEk= X-Google-Smtp-Source: ABdhPJxQNAO5Y7tk+fzaqOmEMdbhAKHXT4Dcp7nj1qAlKx6yfX1eIntZ8bYSfjFraDbxf8UNvYWLtg== X-Received: by 2002:a9d:1465:: with SMTP id h92mr492904oth.141.1612347478149; Wed, 03 Feb 2021 02:17:58 -0800 (PST) Received: from [192.168.88.10] (ip174-67-141-204.no.no.cox.net. [174.67.141.204]) by smtp.googlemail.com with ESMTPSA id d11sm340505oon.21.2021.02.03.02.17.57 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 03 Feb 2021 02:17:57 -0800 (PST) Subject: Re: [Question][PGAgent][Jobs] - Problems running sh scripts on remote Server To: pgsql-admin@lists.postgresql.org References: From: Ron Message-ID: <0373854d-8b58-3101-40de-c1b83d891f6a@gmail.com> Date: Wed, 3 Feb 2021 04:17:56 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/alternative; boundary="------------CC439204C06441F2731C4BA4" Content-Language: en-US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk This is a multi-part message in MIME format. --------------CC439204C06441F2731C4BA4 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit You'll probably have better luck asking a pgadmin list: https://www.pgadmin.org/support/list/. On 2/3/21 4:13 AM, João Gaspar wrote: > Hi to all, > I'm a young padawan in RHEL PostgreSQL configurations. > My past experience was in Windows Server with .bat scripts. > > My Environment specs: > Client OS: Win10 Pro > PgAdmin 4.30 > > Remote Server with PG > Remote OS: RHEL8.3 > PG Version: 13.1 > PG Agent: 4.0 > > Background history: > I set up pgagent based on this adapted to pg_agent13 and documentation: > https://www.pgadmin.org/docs/pgadmin4/development/using_pgagent.html > > https://stackoverflow.com/questions/52168081/systemd-unit-for-pgagent > > My job is a sh script that makes the daily backups. I test the script and > run as expected on a remote server but when configure the job in PgAdmin > Win10 Client using in the Code box /pathtoscript/script.sh isn´t working > when I click on Run Now. > > I try to put: > > sh /pathtoscript/script.sh - Don't do anything to the folder of backups > > /pathtoscript/script.sh - Don't do anything to the folder of backups > > > Checking the /var/log/pgagent_13.log I see that pgagent establish the > connection and Execute the job: > > Wed Feb 3 10:04:00 2021 DEBUG: Creating DB connection: user=postgres >  hostaddr=127.0.0.1 port=5432 dbname=postgres > > Wed Feb 3 10:04:00 2021 DEBUG: Parsing connection information... > Wed Feb 3 10:04:00 2021 DEBUG: Allocating new connection for the database > with connection string: user=postgres dbname=postgres hostaddr=127.0.0.1 > port=5432... > Wed Feb 3 10:04:00 2021 DEBUG: Starting job: 1 > Wed Feb 3 10:04:00 2021 DEBUG: Executing batch step1(part of job 1) > Wed Feb 3 10:04:00 2021 DEBUG: Creating primary connection > Wed Feb 3 10:04:00 2021 DEBUG: Parsing connection information... > Wed Feb 3 10:04:00 2021 DEBUG: user: postgres > Wed Feb 3 10:04:00 2021 DEBUG: dbname: postgres > Wed Feb 3 10:04:00 2021 DEBUG: hostaddr: 127.0.0.1 > Wed Feb 3 10:04:00 2021 DEBUG: port: 5432 > Wed Feb 3 10:04:00 2021 DEBUG: Creating DB connection: user=postgres >  hostaddr=127.0.0.1 port=5432 dbname=postgres > Wed Feb 3 10:04:00 2021 DEBUG: Database sanity check > Wed Feb 3 10:04:00 2021 DEBUG: Clearing zombies > Wed Feb 3 10:04:00 2021 DEBUG: Checking for jobs to run > Wed Feb 3 10:04:00 2021 DEBUG: Sleeping... > > My question this can be a read/write permissions on destination folder to > the user pgagent? > > Thank you for your time and I'm sorry if I'm asking a silly question. > > > Best regards, > João Gaspar -- Angular momentum makes the world go 'round. --------------CC439204C06441F2731C4BA4 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit You'll probably have better luck asking a pgadmin list: https://www.pgadmin.org/support/list/.

On 2/3/21 4:13 AM, João Gaspar wrote:
Hi to all,
I'm a young padawan in RHEL PostgreSQL configurations.
My past experience was in Windows Server with .bat scripts.

My Environment specs:
Client OS: Win10 Pro
PgAdmin 4.30

Remote Server with PG
Remote OS: RHEL8.3
PG Version: 13.1
PG Agent: 4.0

Background history:
I set up pgagent based on this adapted to pg_agent13 and documentation:

https://stackoverflow.com/questions/52168081/systemd-unit-for-pgagent 

My job is a sh script that makes the daily backups. I test the script and run as expected on a remote server but when configure the job in PgAdmin Win10 Client using in the Code box /pathtoscript/script.sh isn´t working when I click on Run Now.

I try to put:

sh /pathtoscript/script.sh - Don't do anything to the folder of backups

/pathtoscript/script.sh - Don't do anything to the folder of backups


Checking  the /var/log/pgagent_13.log I see that pgagent establish the connection and Execute the job:

Wed Feb 3 10:04:00 2021 DEBUG: Creating DB connection: user=postgres  hostaddr=127.0.0.1 port=5432 dbname=postgres

Wed Feb 3 10:04:00 2021 DEBUG: Parsing connection information...
Wed Feb 3 10:04:00 2021 DEBUG: Allocating new connection for the database with connection string: user=postgres dbname=postgres hostaddr=127.0.0.1 port=5432...
Wed Feb 3 10:04:00 2021 DEBUG: Starting job: 1
Wed Feb 3 10:04:00 2021 DEBUG: Executing batch step1(part of job 1)
Wed Feb 3 10:04:00 2021 DEBUG: Creating primary connection
Wed Feb 3 10:04:00 2021 DEBUG: Parsing connection information...
Wed Feb 3 10:04:00 2021 DEBUG: user: postgres
Wed Feb 3 10:04:00 2021 DEBUG: dbname: postgres
Wed Feb 3 10:04:00 2021 DEBUG: hostaddr: 127.0.0.1
Wed Feb 3 10:04:00 2021 DEBUG: port: 5432
Wed Feb 3 10:04:00 2021 DEBUG: Creating DB connection: user=postgres  hostaddr=127.0.0.1 port=5432 dbname=postgres
Wed Feb 3 10:04:00 2021 DEBUG: Database sanity check
Wed Feb 3 10:04:00 2021 DEBUG: Clearing zombies
Wed Feb 3 10:04:00 2021 DEBUG: Checking for jobs to run
Wed Feb 3 10:04:00 2021 DEBUG: Sleeping...

My question this can be a read/write permissions on destination folder to the user pgagent?

Thank you for your time and I'm sorry if I'm asking a silly question.


Best regards,
João Gaspar

--
Angular momentum makes the world go 'round.
--------------CC439204C06441F2731C4BA4--