Page 1 of 1

Copy the root file from chron with a script?

Posted: Mon Jan 01, 2024 2:17 pm
by theroar84

I have a simple script that copies a few files from a USB stick for me. Fossa64 9.5 Multiple Frugal on EXT4 hard drives.

I have setup a few jobs in pSchedule and want to update the root file on a few PC's. The script can copy normal files fine... but it does not "see" the root file.

This is the script. The first line works as expected and adds the scripts I call in the updated pSchedule list. The second line skips root, but did copy the test.txt file I added to the folder. Thanks again for all the tips!

#!/bin/bash
cp /mnt/sdb1/1a/app/. /root/my-applications/bin/
cp /mnt/sdb1/1a/nroot/. /var/spool/cron/crontabs/

This image https://imgur.com/a/n0REx1Q shows how the text file copied fine... but no root update.


Re: Copy the root file from chron with a script?

Posted: Mon Jan 01, 2024 3:02 pm
by Chelsea80

@ theroar84

FYI:

This what I see on your post, all OK
.

On Forum.png
On Forum.png (159.58 KiB) Viewed 509 times

.
This what I see when clicking on above
.

On Link.png
On Link.png (14.17 KiB) Viewed 509 times

.
Best wishes

Chelsea80


Re: Copy the root file from chron with a script?

Posted: Mon Jan 01, 2024 3:32 pm
by theroar84

Thank you. I will see what happens when I post it as a image instead of just dropping the link in there.

Update: I think I was told before it is a Imgur thing. When I add it as a image it gives an error... paste the link... the image shows up, but as you noted if you click it you get an error. My final strategy was to add the link as a url above, then paste the imgur link so it is visible in the post too.


Re: Copy the root file from chron with a script?

Posted: Mon Jan 01, 2024 3:44 pm
by fredx181

@theroar84 This should work:
cp -rT /mnt/sdb1/1a/nroot/ /var/spool/cron/crontabs/ (-r = recursive and -T (--no-target-directory) option, this copies everything, including hidden files, symlinks, folders).

EDIT: Or if you want to force overwriting (-f option) :
cp -rfT /mnt/sdb1/1a/nroot/ /var/spool/cron/crontabs/
Or if you want all permissions to be preserved too (-a option = archive)
cp -afT /mnt/sdb1/1a/nroot/ /var/spool/cron/crontabs/


Re: Copy the root file from chron with a script?

Posted: Mon Jan 01, 2024 3:51 pm
by Trapster

Since you have no suffix on the "root" file, use * instead of *.*

Code: Select all

cp /mnt/sdb1/1a/nroot/* /var/spool/cron/crontabs/

Re: Copy the root file from chron with a script?

Posted: Tue Jan 02, 2024 1:37 pm
by theroar84

Thanks tons for all the tips! Really cool to add the extra commands to the script to force the exact results. 👍

The archive option was the one that I finally settled on. Keeping the permissions was sweet. Thanks fredx181!

cp -afT /mnt/sdb1/1a/nroot/ /var/spool/cron/crontabs/
Or if you want all permissions to be preserved too (-a option = archive)

I did find out that just removing the * for the extension did not work. A cool option to test though. I never would have thought of that. 🤦‍♂️


Re: Copy the root file from chron with a script?

Posted: Fri Jan 05, 2024 2:18 pm
by theroar84

Just wanted to say thanks again. The update process was so slick.