pct exec -> Syntax -c " ' "-> how to solve?

PTR

New Member
Feb 20, 2022
10
0
1
42
Code:
pct exec 7000 -- bash -c "echo 'APT::periodic::Update-Package-Lists "1";
      APT::periodic::Download-Upgradeable-Packages "1";
      APT::periodic::AutocleanInterval "7";
      APT::periodic::Unattended-Upgrade "1";' > /etc/apt/apt.conf.d/20auto-upgrades"

answer:
Code:
bash: -c: option requires an argument


-> to many cascaded " is the problem?
How can I solve that syntax problem? \" does not work....


As above but clearly structured:
Code:
pct exec 7000 -- bash -c
 "
   echo '
             APT::periodic::Update-Package-Lists "1";
             APT::periodic::Download-Upgradeable-Packages "1";
             APT::periodic::AutocleanInterval "7";
             APT::periodic::Unattended-Upgrade "1";
            '
   > /etc/apt/apt.conf.d/20auto-upgrades
 "
 
Last edited:
I'm not totally sure what goes wrong here but what works is adding -e for echo and setting newlines manually. This might help you in figuring out whats going wrong :)

Code:
pct exec 7000 -- bash -c "echo -e 'APT::periodic::Update-Package-Lists "1";\nAPT::periodic::Download-Upgradeable-Packages "1";\nAPT::periodic::AutocleanInterval "7";\nAPT::periodic::Unattended-Upgrade "1";\n' > /etc/apt/apt.conf.d/20auto-upgrades"