systemd and copy (/bin/cp): no such file or directory Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) 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
Does using the Inspiration rules for character defects encourage My Guy Syndrome?
"Destructive force" carried by a B-52?
Why do C and C++ allow the expression (int) + 4*5?
Suing a Police Officer Instead of the Police Department
Does Prince Arnaud cause someone holding the Princess to lose?
Who's this lady in the war room?
How do I deal with an erroneously large refund?
Why does BitLocker not use RSA?
How was Lagrange appointed professor of mathematics so early?
Why did Bronn offer to be Tyrion Lannister's champion in trial by combat?
What were wait-states, and why was it only an issue for PCs?
What documents does someone with a long-term visa need to travel to another Schengen country?
2 sample t test for sample sizes - 30,000 and 150,000
Is there a verb for listening stealthily?
Can the van der Waals coefficients be negative in the van der Waals equation for real gases?
Does traveling In The United States require a passport or can I use my green card if not a US citizen?
What helicopter has the most rotor blades?
Why aren't road bike wheels tiny?
Recursive calls to a function - why is the address of the parameter passed to it lowering with each call?
tabularx column has extra padding at right?
Determine the generator of an ideal of ring of integers
What came first? Venom as the movie or as the song?
/bin/ls sorts differently than just ls
Raising a bilingual kid. When should we introduce the majority language?
systemd and copy (/bin/cp): no such file or directory
Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern)
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.
yesterday
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 yesterday
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.
yesterday
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.
yesterday
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.
yesterday
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.
yesterday
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
yesterday
1
Related: unix.stackexchange.com/questions/216780/…
– steve
yesterday
1
@steve Ok, so it has some very basic shell capabilities, but filename generation does not seem to be one of them.
– Kusalananda♦
yesterday
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
yesterday
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
yesterday
|
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
yesterday
1
Related: unix.stackexchange.com/questions/216780/…
– steve
yesterday
1
@steve Ok, so it has some very basic shell capabilities, but filename generation does not seem to be one of them.
– Kusalananda♦
yesterday
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
yesterday
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
yesterday
|
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
yesterday
1
Related: unix.stackexchange.com/questions/216780/…
– steve
yesterday
1
@steve Ok, so it has some very basic shell capabilities, but filename generation does not seem to be one of them.
– Kusalananda♦
yesterday
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
yesterday
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
yesterday
|
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 yesterday
answered yesterday
Kusalananda♦Kusalananda
143k18267443
143k18267443
tested the first method, modifying to: ExecStart=/bin/sh -c '/bin/cp -rv /opt/test-bak/* /opt/test/' Works smoothly, thanks!
– Koay Chiang Teik
yesterday
1
Related: unix.stackexchange.com/questions/216780/…
– steve
yesterday
1
@steve Ok, so it has some very basic shell capabilities, but filename generation does not seem to be one of them.
– Kusalananda♦
yesterday
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
yesterday
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
yesterday
|
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
yesterday
1
Related: unix.stackexchange.com/questions/216780/…
– steve
yesterday
1
@steve Ok, so it has some very basic shell capabilities, but filename generation does not seem to be one of them.
– Kusalananda♦
yesterday
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
yesterday
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
yesterday
tested the first method, modifying to: ExecStart=/bin/sh -c '/bin/cp -rv /opt/test-bak/* /opt/test/' Works smoothly, thanks!
– Koay Chiang Teik
yesterday
tested the first method, modifying to: ExecStart=/bin/sh -c '/bin/cp -rv /opt/test-bak/* /opt/test/' Works smoothly, thanks!
– Koay Chiang Teik
yesterday
1
1
Related: unix.stackexchange.com/questions/216780/…
– steve
yesterday
Related: unix.stackexchange.com/questions/216780/…
– steve
yesterday
1
1
@steve Ok, so it has some very basic shell capabilities, but filename generation does not seem to be one of them.
– Kusalananda♦
yesterday
@steve Ok, so it has some very basic shell capabilities, but filename generation does not seem to be one of them.
– Kusalananda♦
yesterday
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
yesterday
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
yesterday
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
yesterday
@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
yesterday
|
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.
yesterday