View previous topic :: View next topic |
Author |
Message |
mickwish Jr. Member

Joined: 30 Aug 2025 Posts: 86 Location: Brisbane, Australia
|
|
Back to top |
|
mickwish Jr. Member

Joined: 30 Aug 2025 Posts: 86 Location: Brisbane, Australia
|
Posted: Sat Sep 27, 2025 9:59 am Post subject: |
|
|
Ok, the main problem seems to be that it won't write to the file "crontab.txt" Yet this is what the instructions says here. Have found some other errors in the script, but even fixing them fails to get the file created with the name crontab.txt. Any ideas?
Thanks
Mick
_________________ Kubuntu
|
|
Back to top |
|
pbharris Member

Joined: 02 Jul 2025 Posts: 320 Location: chicago
|
Posted: Sat Sep 27, 2025 3:28 pm Post subject: |
|
|
hello,
assuming the paths are good:
Code: |
CRONTXT=/mnt/HD_a2/crontab.txt
# start with existing crontab
/bin/crontab -l > $CRONTXT
# add the Rsync shell script to cron
/bin/echo "0 3 * * * /mnt/HD_a2/sync_backup.sh \
/mnt/HD_a2/fun_plug.d/log/rsync.last.log 2>&1" >> $CRONTXT
# install the new crontab
/bin/crontab $CRONTXT
# clean up
/bin/rm $CRONTXT
|
Do you get any output from the command /mnt/HD_a2/sync_backup.sh /mnt/HD_a2/fun_plug.d/log/rsync.last.log
_________________ Fedora
|
|
Back to top |
|
mickwish Jr. Member

Joined: 30 Aug 2025 Posts: 86 Location: Brisbane, Australia
|
Posted: Sat Sep 27, 2025 11:12 pm Post subject: |
|
|
Actually that path was one of the errors: /mnt/HD_a2/fun_plug.d dies not exist in this version.
Have realised I may be trying to run as root, so have changed the commands to run directly and added the rsync from the fun_plug bin instead of /bin, thus: Quote: |
#!/bin/sh
CRONTXT=/mnt/HD_a2/crontab.txt
# start with existing crontab
/bin/crontab -l > $CRONTXT
# add the 2 Rsync shell scripts to cron
/bin/echo "15 9 * * * /mnt/HD_a2/ffp/bin/rsync -rlptDv --delete /mnt/HD_a2 /mnt/HD_b2 >/mnt/HD_a2/ffp/log/rsync.last.log 2>&1" >> $CRONTXT
/bin/echo "0 2 * * mon /mnt/HD_a2/fun_plug.d/bin/rsync -rlptDv --delete /mnt/HD_a2 /mnt/ext >/mnt/HD_a2/fun_plug.d/log/rsync.last.log 2>&1" >> $CRONTXT
# install the new crontab
/bin/crontab $CRONTXT
# clean up
/bin/rm $CRONTXT | Gonna see if it will run this morning for me.... keep you posted.
Thanks
Mick
_________________ Kubuntu
|
|
Back to top |
|
mickwish Jr. Member

Joined: 30 Aug 2025 Posts: 86 Location: Brisbane, Australia
|
Posted: Sun Sep 28, 2025 7:50 am Post subject: |
|
|
Ok, it is not writing to crontab. says the file /mnt/HD_a2/crontab.txt does not exist (actually says No such file or directory2/crontab.txt) - is there a problem with having the _a in the path?? Do I need quotes or something?
Thanks
Mick
_________________ Kubuntu
|
|
Back to top |
|
d_riordan Member

Joined: 08 Jan 2025 Posts: 245 Location: Leominster, Massachusetts, U.S.A.
|
Posted: Thu Oct 02, 2025 10:51 pm Post subject: |
|
|
Path looks fine to me. Underscores are fine in Linux directory and file names. Question stands, does the file / path exist? If you:
Code: | cat /mnt/HD_a2/crontab.txt |
from the command line, do you get any output, or does cat complain that the file doesn't exist as well?
_________________ *buntu 8.04
|
|
Back to top |
|
mickwish Jr. Member

Joined: 30 Aug 2025 Posts: 86 Location: Brisbane, Australia
|
|
Back to top |
|
d_riordan Member

Joined: 08 Jan 2025 Posts: 245 Location: Leominster, Massachusetts, U.S.A.
|
Posted: Fri Oct 03, 2025 2:51 pm Post subject: |
|
|
You might try adding
Code: | tee -a /mnt/HD_a2/COMPINFO/dlink/backuplog.txt |
to the rsync lines of your script to see if rsync is spitting up any errors while running as a cron job.
I recall that the environment for cron is different than your login environment, and I think that this can have an impact on scripts that seem to work just fine when run from the console.
_________________ *buntu 8.04
|
|
Back to top |
|
mushroom Ultimate Member

Joined: 29 Jun 2025 Posts: 2128 Location: Queen Charlotte B. C. Canada
|
Posted: Fri Oct 03, 2025 4:36 pm Post subject: |
|
|
I remember having an issue with a cronjob a while back...
my script would run perfectly when called from the command line but not if called by cron
The script was kept in my home/bin directory in "/home", apparently "/home" was not mounted as executable.
My solution was to create a directory "/ubin" in "/", then a directory "/ubin/each_user" change ownership and permissions of the directory, then move my bin to "/ubin/each_user/bin" and replace it with a symlink.
Once my script was in the same partition as "/bin/bash" everything worked 
_________________ SuSE 8.0, 8.2, 9.0, 9.1, 9.2, 9.3, 10.0, 10.1, 10.2, 10.3, 11.0, 11.1
Live CDs Mepis 8.0, Puppy 4.3.1, netbook- Zenwalk 6.2
|
|
Back to top |
|
mickwish Jr. Member

Joined: 30 Aug 2025 Posts: 86 Location: Brisbane, Australia
|
|
Back to top |
|
mickwish Jr. Member

Joined: 30 Aug 2025 Posts: 86 Location: Brisbane, Australia
|
|
Back to top |
|
d_riordan Member

Joined: 08 Jan 2025 Posts: 245 Location: Leominster, Massachusetts, U.S.A.
|
|
Back to top |
|
Lord.DragonFly.of.Dawn Advanced Member

Joined: 18 Jul 2025 Posts: 606 Location: South Portland, Maine, USA, Earth, Sol System
|
Posted: Mon Oct 20, 2025 12:28 am Post subject: |
|
|
I ran into that problem a few times, but only in specialized uses that required accurate counting of lines processed.
I don't run into it often and it has never caused an error like the one described but it does exist and some scripts may run into it depending on how they process input data.
-P
_________________ ArchLinux x86_64 - Custom Built Desktop
ArchLinux x86_64 - Compaq CQ50 Laptop
ArchLinux i686 - Acer Aspire One Netbook
ArchLinux i686 - Dell Presario ze2000 (w/ shattered LCD)
PuppyLinux, CloneZilla, PartedMagic, DBAN - rescue thumbdrives
Windows 7 (x86_64 desktop alternate boot)
|
|
Back to top |
|
|