systemd and copy (/bin/cp): no such file or directory Unicorn Meta Zoo #1: Why another podcast? Announcing the arrival of Valued Associate #679: Cesar Manara 2019 Community Moderator Election Results Why I closed the “Why is Kali so hard” questionWhy does bash parameter expansion not work inside systemd service files?Migrate socat init script to systemdMake systemd reload only single openvpn process and not the whole groupsystemd says permission denied for /bin/shmysql service restarted during user being connected lead to failing serviceDebian startup script doesn't startWhy x0vncserver is not starting at boot?Failed to start MariaDB database server after upgrade to debian 9Why is systemd stopping service immediately after it is started?systemd: finish the execution of custom shell script before starting nginxsystemd not autorestarting the last docker container after it crashes or kill -9 or docker stop service
Is it OK if I do not take the receipt in Germany?
Philosophers who were composers?
Was Objective-C really a hindrance to Apple software development?
Suing a Police Officer Instead of the Police Department
Why did Israel vote against lifting the American embargo on Cuba?
What is /etc/mtab in Linux?
Why is arima in R one time step off?
Putting Ant-Man on house arrest
When speaking, how do you change your mind mid-sentence?
Getting AggregateResult variables from Execute Anonymous Window
Protagonist's race is hidden - should I reveal it?
Did war bonds have better investment alternatives during WWII?
Where/What are Arya's scars from?
Has a Nobel Peace laureate ever been accused of war crimes?
Determinant of a matrix with 2 equal rows
Bright yellow or light yellow?
How do I deal with an erroneously large refund?
Is it appropriate to mention a relatable company blog post when you're asked about the company?
Is there an efficient way for synchronising audio events real-time with LEDs using an MCU?
What to do with someone that cheated their way though university and a PhD program?
All ASCII characters with a given bit count
What's parked in Mil Moscow helicopter plant?
How did Elite on the NES work?
What is ls Largest Number Formed by only moving two sticks in 508?
systemd and copy (/bin/cp): no such file or directory
Unicorn Meta Zoo #1: Why another podcast?
Announcing the arrival of Valued Associate #679: Cesar Manara
2019 Community Moderator Election Results
Why I closed the “Why is Kali so hard” questionWhy does bash parameter expansion not work inside systemd service files?Migrate socat init script to systemdMake systemd reload only single openvpn process and not the whole groupsystemd says permission denied for /bin/shmysql service restarted during user being connected lead to failing serviceDebian startup script doesn't startWhy x0vncserver is not starting at boot?Failed to start MariaDB database server after upgrade to debian 9Why is systemd stopping service immediately after it is started?systemd: finish the execution of custom shell script before starting nginxsystemd not autorestarting the last docker container after it crashes or kill -9 or docker stop service
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
While manually copying the file the following works, as below:
userx@x:~$ cp -rv /opt/test-bak/* /opt/test/
'/opt/test-bak/file1' -> '/opt/test/file1'
'/opt/test-bak/file2' -> '/opt/test/file2'
'/opt/test-bak/file3' -> '/opt/test/file3'
'/opt/test-bak/subdir1/subfile1' -> '/opt/test/subdir1/subfile1'
'/opt/test-bak/subdir2/subfile2' -> '/opt/test/subdir2/subfile2'
However, installing it as a system service returns the "cannot stat '/opt/test-bak/*': No such file or directory" error
● testcopy.service - test usage of /bin/cp in systemd
Loaded: loaded (/etc/systemd/system/testcopy.service; disabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Sun 2019-04-21 14:55:16 +08; 4min 28s ago
Process: 7872 ExecStart=/bin/cp -rv /opt/test-bak/* /opt/test/ (code=exited, status=1/FAILURE)
Main PID: 7872 (code=exited, status=1/FAILURE)
Apr 21 14:55:15 userx@x systemd[1]: Started test usage of /bin/cp in systemd.
Apr 21 14:55:15 userx@x cp[7872]: /bin/cp: cannot stat '/opt/test-bak/*': No such file or directory
Apr 21 14:55:16 userx@x systemd[1]: testcopy.service: Main process exited, code=exited, status=1/FAILURE
Apr 21 14:55:16 userx@x systemd[1]: testcopy.service: Unit entered failed state.
Apr 21 14:55:16 userx@x systemd[1]: testcopy.service: Failed with result 'exit-code'.
My service file as below:
[Unit]
Description=test usage of /bin/cp in systemd
[Service]
Type=simple
ExecStart=/bin/cp -rv /opt/test-bak/* /opt/test/
[Install]
WantedBy=multi-user.target
Journal shows the below
Apr 21 15:05:12 x systemd[1]: Started test usage of /bin/cp in systemd.
Apr 21 15:05:12 x cp[9892]: /bin/cp: cannot stat '/opt/test-bak/*': No such file or directory
Apr 21 15:05:12 x systemd[1]: testcopy.service: Main process exited, code=exited, status=1/FAILURE
Apr 21 15:05:12 x systemd[1]: testcopy.service: Unit entered failed state.
Apr 21 15:05:12 x systemd[1]: testcopy.service: Failed with result 'exit-code'.
Can anyone shed some light on this?
debian systemd cp file-copy
New contributor
add a comment |
While manually copying the file the following works, as below:
userx@x:~$ cp -rv /opt/test-bak/* /opt/test/
'/opt/test-bak/file1' -> '/opt/test/file1'
'/opt/test-bak/file2' -> '/opt/test/file2'
'/opt/test-bak/file3' -> '/opt/test/file3'
'/opt/test-bak/subdir1/subfile1' -> '/opt/test/subdir1/subfile1'
'/opt/test-bak/subdir2/subfile2' -> '/opt/test/subdir2/subfile2'
However, installing it as a system service returns the "cannot stat '/opt/test-bak/*': No such file or directory" error
● testcopy.service - test usage of /bin/cp in systemd
Loaded: loaded (/etc/systemd/system/testcopy.service; disabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Sun 2019-04-21 14:55:16 +08; 4min 28s ago
Process: 7872 ExecStart=/bin/cp -rv /opt/test-bak/* /opt/test/ (code=exited, status=1/FAILURE)
Main PID: 7872 (code=exited, status=1/FAILURE)
Apr 21 14:55:15 userx@x systemd[1]: Started test usage of /bin/cp in systemd.
Apr 21 14:55:15 userx@x cp[7872]: /bin/cp: cannot stat '/opt/test-bak/*': No such file or directory
Apr 21 14:55:16 userx@x systemd[1]: testcopy.service: Main process exited, code=exited, status=1/FAILURE
Apr 21 14:55:16 userx@x systemd[1]: testcopy.service: Unit entered failed state.
Apr 21 14:55:16 userx@x systemd[1]: testcopy.service: Failed with result 'exit-code'.
My service file as below:
[Unit]
Description=test usage of /bin/cp in systemd
[Service]
Type=simple
ExecStart=/bin/cp -rv /opt/test-bak/* /opt/test/
[Install]
WantedBy=multi-user.target
Journal shows the below
Apr 21 15:05:12 x systemd[1]: Started test usage of /bin/cp in systemd.
Apr 21 15:05:12 x cp[9892]: /bin/cp: cannot stat '/opt/test-bak/*': No such file or directory
Apr 21 15:05:12 x systemd[1]: testcopy.service: Main process exited, code=exited, status=1/FAILURE
Apr 21 15:05:12 x systemd[1]: testcopy.service: Unit entered failed state.
Apr 21 15:05:12 x systemd[1]: testcopy.service: Failed with result 'exit-code'.
Can anyone shed some light on this?
debian systemd cp file-copy
New contributor
You should set the type of service to oneshot as that type is only ensured not to already be running when started and not restarted when it exits.
– Dan D.
2 days ago
add a comment |
While manually copying the file the following works, as below:
userx@x:~$ cp -rv /opt/test-bak/* /opt/test/
'/opt/test-bak/file1' -> '/opt/test/file1'
'/opt/test-bak/file2' -> '/opt/test/file2'
'/opt/test-bak/file3' -> '/opt/test/file3'
'/opt/test-bak/subdir1/subfile1' -> '/opt/test/subdir1/subfile1'
'/opt/test-bak/subdir2/subfile2' -> '/opt/test/subdir2/subfile2'
However, installing it as a system service returns the "cannot stat '/opt/test-bak/*': No such file or directory" error
● testcopy.service - test usage of /bin/cp in systemd
Loaded: loaded (/etc/systemd/system/testcopy.service; disabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Sun 2019-04-21 14:55:16 +08; 4min 28s ago
Process: 7872 ExecStart=/bin/cp -rv /opt/test-bak/* /opt/test/ (code=exited, status=1/FAILURE)
Main PID: 7872 (code=exited, status=1/FAILURE)
Apr 21 14:55:15 userx@x systemd[1]: Started test usage of /bin/cp in systemd.
Apr 21 14:55:15 userx@x cp[7872]: /bin/cp: cannot stat '/opt/test-bak/*': No such file or directory
Apr 21 14:55:16 userx@x systemd[1]: testcopy.service: Main process exited, code=exited, status=1/FAILURE
Apr 21 14:55:16 userx@x systemd[1]: testcopy.service: Unit entered failed state.
Apr 21 14:55:16 userx@x systemd[1]: testcopy.service: Failed with result 'exit-code'.
My service file as below:
[Unit]
Description=test usage of /bin/cp in systemd
[Service]
Type=simple
ExecStart=/bin/cp -rv /opt/test-bak/* /opt/test/
[Install]
WantedBy=multi-user.target
Journal shows the below
Apr 21 15:05:12 x systemd[1]: Started test usage of /bin/cp in systemd.
Apr 21 15:05:12 x cp[9892]: /bin/cp: cannot stat '/opt/test-bak/*': No such file or directory
Apr 21 15:05:12 x systemd[1]: testcopy.service: Main process exited, code=exited, status=1/FAILURE
Apr 21 15:05:12 x systemd[1]: testcopy.service: Unit entered failed state.
Apr 21 15:05:12 x systemd[1]: testcopy.service: Failed with result 'exit-code'.
Can anyone shed some light on this?
debian systemd cp file-copy
New contributor
While manually copying the file the following works, as below:
userx@x:~$ cp -rv /opt/test-bak/* /opt/test/
'/opt/test-bak/file1' -> '/opt/test/file1'
'/opt/test-bak/file2' -> '/opt/test/file2'
'/opt/test-bak/file3' -> '/opt/test/file3'
'/opt/test-bak/subdir1/subfile1' -> '/opt/test/subdir1/subfile1'
'/opt/test-bak/subdir2/subfile2' -> '/opt/test/subdir2/subfile2'
However, installing it as a system service returns the "cannot stat '/opt/test-bak/*': No such file or directory" error
● testcopy.service - test usage of /bin/cp in systemd
Loaded: loaded (/etc/systemd/system/testcopy.service; disabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Sun 2019-04-21 14:55:16 +08; 4min 28s ago
Process: 7872 ExecStart=/bin/cp -rv /opt/test-bak/* /opt/test/ (code=exited, status=1/FAILURE)
Main PID: 7872 (code=exited, status=1/FAILURE)
Apr 21 14:55:15 userx@x systemd[1]: Started test usage of /bin/cp in systemd.
Apr 21 14:55:15 userx@x cp[7872]: /bin/cp: cannot stat '/opt/test-bak/*': No such file or directory
Apr 21 14:55:16 userx@x systemd[1]: testcopy.service: Main process exited, code=exited, status=1/FAILURE
Apr 21 14:55:16 userx@x systemd[1]: testcopy.service: Unit entered failed state.
Apr 21 14:55:16 userx@x systemd[1]: testcopy.service: Failed with result 'exit-code'.
My service file as below:
[Unit]
Description=test usage of /bin/cp in systemd
[Service]
Type=simple
ExecStart=/bin/cp -rv /opt/test-bak/* /opt/test/
[Install]
WantedBy=multi-user.target
Journal shows the below
Apr 21 15:05:12 x systemd[1]: Started test usage of /bin/cp in systemd.
Apr 21 15:05:12 x cp[9892]: /bin/cp: cannot stat '/opt/test-bak/*': No such file or directory
Apr 21 15:05:12 x systemd[1]: testcopy.service: Main process exited, code=exited, status=1/FAILURE
Apr 21 15:05:12 x systemd[1]: testcopy.service: Unit entered failed state.
Apr 21 15:05:12 x systemd[1]: testcopy.service: Failed with result 'exit-code'.
Can anyone shed some light on this?
debian systemd cp file-copy
debian systemd cp file-copy
New contributor
New contributor
New contributor
asked 2 days ago
Koay Chiang TeikKoay Chiang Teik
232
232
New contributor
New contributor
You should set the type of service to oneshot as that type is only ensured not to already be running when started and not restarted when it exits.
– Dan D.
2 days ago
add a comment |
You should set the type of service to oneshot as that type is only ensured not to already be running when started and not restarted when it exits.
– Dan D.
2 days ago
You should set the type of service to oneshot as that type is only ensured not to already be running when started and not restarted when it exits.
– Dan D.
2 days ago
You should set the type of service to oneshot as that type is only ensured not to already be running when started and not restarted when it exits.
– Dan D.
2 days ago
add a comment |
1 Answer
1
active
oldest
votes
When using filename globbing patterns on the command line, it's the shell that expands the globbing patterns to filenames that match them, creating a list of pathnames that is then passed on to the utility that you are calling (cp
here).
The command that you specify with ExecStart
in your service file will not run in a shell. This means that the filename globbing pattern *
will not be expanded and that cp
will be called with /opt/test-bak/*
as the single literal source path to copy.
You could try wrapping your command in an in-line shell script:
ExecStart=/bin/sh -c '/bin/cp -rv /opt/test-bak/* /opt/test/'
Or, wrap your command in a short shell script,
#!/bin/sh
/bin/cp -rv /opt/test-bak/* /opt/test/
and then call that instead.
Since I know virtually nothing about systemd, there may be better ways to do this though.
Note that if the *
glob does not match anything (because the directory is empty), then you would have the same issue as before. An unmatched globbing pattern will by default be left unexpanded.
Personally, I would use either
cd /opt/test-bak && /bin/cp -Rp -v . /opt/test
or
rsync -ai /opt/test/bak-test/ /opt/test
Since neither of these rely on the shell doing filename generation, they could both run without a wrapping shell. Not relying on a shell glob would also, in this case, ensure that hidden files and directories in bak-test
will get copied.
tested the first method, modifying to: ExecStart=/bin/sh -c '/bin/cp -rv /opt/test-bak/* /opt/test/' Works smoothly, thanks!
– Koay Chiang Teik
2 days ago
1
Related: unix.stackexchange.com/questions/216780/…
– steve
2 days ago
1
@steve Ok, so it has some very basic shell capabilities, but filename generation does not seem to be one of them.
– Kusalananda♦
2 days ago
For best results when running the command via a shell,exec
thecp
. Do not rely upon a shell doing this implicitly. Chain load dæmons, rather than leaving shell parent processes lying around.
– JdeBP
2 days ago
1
@kusalananda, I tested your versioncp -rv /opt/test/bak-test/ /opt/test
, which is not the intended outcome of this question, as it results in nesting thebak-test
folder into the/opt/test
folder. The example using rsync is a good option, thanks for pointing it out. I would have tried rsync next but I was stumped why cp wouldn't work even after triple checking everything.
– Koay Chiang Teik
2 days ago
|
show 5 more comments
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Koay Chiang Teik is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f513633%2fsystemd-and-copy-bin-cp-no-such-file-or-directory%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
When using filename globbing patterns on the command line, it's the shell that expands the globbing patterns to filenames that match them, creating a list of pathnames that is then passed on to the utility that you are calling (cp
here).
The command that you specify with ExecStart
in your service file will not run in a shell. This means that the filename globbing pattern *
will not be expanded and that cp
will be called with /opt/test-bak/*
as the single literal source path to copy.
You could try wrapping your command in an in-line shell script:
ExecStart=/bin/sh -c '/bin/cp -rv /opt/test-bak/* /opt/test/'
Or, wrap your command in a short shell script,
#!/bin/sh
/bin/cp -rv /opt/test-bak/* /opt/test/
and then call that instead.
Since I know virtually nothing about systemd, there may be better ways to do this though.
Note that if the *
glob does not match anything (because the directory is empty), then you would have the same issue as before. An unmatched globbing pattern will by default be left unexpanded.
Personally, I would use either
cd /opt/test-bak && /bin/cp -Rp -v . /opt/test
or
rsync -ai /opt/test/bak-test/ /opt/test
Since neither of these rely on the shell doing filename generation, they could both run without a wrapping shell. Not relying on a shell glob would also, in this case, ensure that hidden files and directories in bak-test
will get copied.
tested the first method, modifying to: ExecStart=/bin/sh -c '/bin/cp -rv /opt/test-bak/* /opt/test/' Works smoothly, thanks!
– Koay Chiang Teik
2 days ago
1
Related: unix.stackexchange.com/questions/216780/…
– steve
2 days ago
1
@steve Ok, so it has some very basic shell capabilities, but filename generation does not seem to be one of them.
– Kusalananda♦
2 days ago
For best results when running the command via a shell,exec
thecp
. Do not rely upon a shell doing this implicitly. Chain load dæmons, rather than leaving shell parent processes lying around.
– JdeBP
2 days ago
1
@kusalananda, I tested your versioncp -rv /opt/test/bak-test/ /opt/test
, which is not the intended outcome of this question, as it results in nesting thebak-test
folder into the/opt/test
folder. The example using rsync is a good option, thanks for pointing it out. I would have tried rsync next but I was stumped why cp wouldn't work even after triple checking everything.
– Koay Chiang Teik
2 days ago
|
show 5 more comments
When using filename globbing patterns on the command line, it's the shell that expands the globbing patterns to filenames that match them, creating a list of pathnames that is then passed on to the utility that you are calling (cp
here).
The command that you specify with ExecStart
in your service file will not run in a shell. This means that the filename globbing pattern *
will not be expanded and that cp
will be called with /opt/test-bak/*
as the single literal source path to copy.
You could try wrapping your command in an in-line shell script:
ExecStart=/bin/sh -c '/bin/cp -rv /opt/test-bak/* /opt/test/'
Or, wrap your command in a short shell script,
#!/bin/sh
/bin/cp -rv /opt/test-bak/* /opt/test/
and then call that instead.
Since I know virtually nothing about systemd, there may be better ways to do this though.
Note that if the *
glob does not match anything (because the directory is empty), then you would have the same issue as before. An unmatched globbing pattern will by default be left unexpanded.
Personally, I would use either
cd /opt/test-bak && /bin/cp -Rp -v . /opt/test
or
rsync -ai /opt/test/bak-test/ /opt/test
Since neither of these rely on the shell doing filename generation, they could both run without a wrapping shell. Not relying on a shell glob would also, in this case, ensure that hidden files and directories in bak-test
will get copied.
tested the first method, modifying to: ExecStart=/bin/sh -c '/bin/cp -rv /opt/test-bak/* /opt/test/' Works smoothly, thanks!
– Koay Chiang Teik
2 days ago
1
Related: unix.stackexchange.com/questions/216780/…
– steve
2 days ago
1
@steve Ok, so it has some very basic shell capabilities, but filename generation does not seem to be one of them.
– Kusalananda♦
2 days ago
For best results when running the command via a shell,exec
thecp
. Do not rely upon a shell doing this implicitly. Chain load dæmons, rather than leaving shell parent processes lying around.
– JdeBP
2 days ago
1
@kusalananda, I tested your versioncp -rv /opt/test/bak-test/ /opt/test
, which is not the intended outcome of this question, as it results in nesting thebak-test
folder into the/opt/test
folder. The example using rsync is a good option, thanks for pointing it out. I would have tried rsync next but I was stumped why cp wouldn't work even after triple checking everything.
– Koay Chiang Teik
2 days ago
|
show 5 more comments
When using filename globbing patterns on the command line, it's the shell that expands the globbing patterns to filenames that match them, creating a list of pathnames that is then passed on to the utility that you are calling (cp
here).
The command that you specify with ExecStart
in your service file will not run in a shell. This means that the filename globbing pattern *
will not be expanded and that cp
will be called with /opt/test-bak/*
as the single literal source path to copy.
You could try wrapping your command in an in-line shell script:
ExecStart=/bin/sh -c '/bin/cp -rv /opt/test-bak/* /opt/test/'
Or, wrap your command in a short shell script,
#!/bin/sh
/bin/cp -rv /opt/test-bak/* /opt/test/
and then call that instead.
Since I know virtually nothing about systemd, there may be better ways to do this though.
Note that if the *
glob does not match anything (because the directory is empty), then you would have the same issue as before. An unmatched globbing pattern will by default be left unexpanded.
Personally, I would use either
cd /opt/test-bak && /bin/cp -Rp -v . /opt/test
or
rsync -ai /opt/test/bak-test/ /opt/test
Since neither of these rely on the shell doing filename generation, they could both run without a wrapping shell. Not relying on a shell glob would also, in this case, ensure that hidden files and directories in bak-test
will get copied.
When using filename globbing patterns on the command line, it's the shell that expands the globbing patterns to filenames that match them, creating a list of pathnames that is then passed on to the utility that you are calling (cp
here).
The command that you specify with ExecStart
in your service file will not run in a shell. This means that the filename globbing pattern *
will not be expanded and that cp
will be called with /opt/test-bak/*
as the single literal source path to copy.
You could try wrapping your command in an in-line shell script:
ExecStart=/bin/sh -c '/bin/cp -rv /opt/test-bak/* /opt/test/'
Or, wrap your command in a short shell script,
#!/bin/sh
/bin/cp -rv /opt/test-bak/* /opt/test/
and then call that instead.
Since I know virtually nothing about systemd, there may be better ways to do this though.
Note that if the *
glob does not match anything (because the directory is empty), then you would have the same issue as before. An unmatched globbing pattern will by default be left unexpanded.
Personally, I would use either
cd /opt/test-bak && /bin/cp -Rp -v . /opt/test
or
rsync -ai /opt/test/bak-test/ /opt/test
Since neither of these rely on the shell doing filename generation, they could both run without a wrapping shell. Not relying on a shell glob would also, in this case, ensure that hidden files and directories in bak-test
will get copied.
edited 2 days ago
answered 2 days ago
Kusalananda♦Kusalananda
143k18267444
143k18267444
tested the first method, modifying to: ExecStart=/bin/sh -c '/bin/cp -rv /opt/test-bak/* /opt/test/' Works smoothly, thanks!
– Koay Chiang Teik
2 days ago
1
Related: unix.stackexchange.com/questions/216780/…
– steve
2 days ago
1
@steve Ok, so it has some very basic shell capabilities, but filename generation does not seem to be one of them.
– Kusalananda♦
2 days ago
For best results when running the command via a shell,exec
thecp
. Do not rely upon a shell doing this implicitly. Chain load dæmons, rather than leaving shell parent processes lying around.
– JdeBP
2 days ago
1
@kusalananda, I tested your versioncp -rv /opt/test/bak-test/ /opt/test
, which is not the intended outcome of this question, as it results in nesting thebak-test
folder into the/opt/test
folder. The example using rsync is a good option, thanks for pointing it out. I would have tried rsync next but I was stumped why cp wouldn't work even after triple checking everything.
– Koay Chiang Teik
2 days ago
|
show 5 more comments
tested the first method, modifying to: ExecStart=/bin/sh -c '/bin/cp -rv /opt/test-bak/* /opt/test/' Works smoothly, thanks!
– Koay Chiang Teik
2 days ago
1
Related: unix.stackexchange.com/questions/216780/…
– steve
2 days ago
1
@steve Ok, so it has some very basic shell capabilities, but filename generation does not seem to be one of them.
– Kusalananda♦
2 days ago
For best results when running the command via a shell,exec
thecp
. Do not rely upon a shell doing this implicitly. Chain load dæmons, rather than leaving shell parent processes lying around.
– JdeBP
2 days ago
1
@kusalananda, I tested your versioncp -rv /opt/test/bak-test/ /opt/test
, which is not the intended outcome of this question, as it results in nesting thebak-test
folder into the/opt/test
folder. The example using rsync is a good option, thanks for pointing it out. I would have tried rsync next but I was stumped why cp wouldn't work even after triple checking everything.
– Koay Chiang Teik
2 days ago
tested the first method, modifying to: ExecStart=/bin/sh -c '/bin/cp -rv /opt/test-bak/* /opt/test/' Works smoothly, thanks!
– Koay Chiang Teik
2 days ago
tested the first method, modifying to: ExecStart=/bin/sh -c '/bin/cp -rv /opt/test-bak/* /opt/test/' Works smoothly, thanks!
– Koay Chiang Teik
2 days ago
1
1
Related: unix.stackexchange.com/questions/216780/…
– steve
2 days ago
Related: unix.stackexchange.com/questions/216780/…
– steve
2 days ago
1
1
@steve Ok, so it has some very basic shell capabilities, but filename generation does not seem to be one of them.
– Kusalananda♦
2 days ago
@steve Ok, so it has some very basic shell capabilities, but filename generation does not seem to be one of them.
– Kusalananda♦
2 days ago
For best results when running the command via a shell,
exec
the cp
. Do not rely upon a shell doing this implicitly. Chain load dæmons, rather than leaving shell parent processes lying around.– JdeBP
2 days ago
For best results when running the command via a shell,
exec
the cp
. Do not rely upon a shell doing this implicitly. Chain load dæmons, rather than leaving shell parent processes lying around.– JdeBP
2 days ago
1
1
@kusalananda, I tested your version
cp -rv /opt/test/bak-test/ /opt/test
, which is not the intended outcome of this question, as it results in nesting the bak-test
folder into the /opt/test
folder. The example using rsync is a good option, thanks for pointing it out. I would have tried rsync next but I was stumped why cp wouldn't work even after triple checking everything.– Koay Chiang Teik
2 days ago
@kusalananda, I tested your version
cp -rv /opt/test/bak-test/ /opt/test
, which is not the intended outcome of this question, as it results in nesting the bak-test
folder into the /opt/test
folder. The example using rsync is a good option, thanks for pointing it out. I would have tried rsync next but I was stumped why cp wouldn't work even after triple checking everything.– Koay Chiang Teik
2 days ago
|
show 5 more comments
Koay Chiang Teik is a new contributor. Be nice, and check out our Code of Conduct.
Koay Chiang Teik is a new contributor. Be nice, and check out our Code of Conduct.
Koay Chiang Teik is a new contributor. Be nice, and check out our Code of Conduct.
Koay Chiang Teik is a new contributor. Be nice, and check out our Code of Conduct.
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f513633%2fsystemd-and-copy-bin-cp-no-such-file-or-directory%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
You should set the type of service to oneshot as that type is only ensured not to already be running when started and not restarted when it exits.
– Dan D.
2 days ago