Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I am using a HP Probook and have done a rsync executeb by task scheduler on KDE Neon Plasma.
I am using this script for the past 2 years and it just works, but recently, it works only at times. When it works, it produces one format of log file, when however i execute it manually, the same script produces another outpit format.
So, how do I find out, why it is not working at time - for example, the last 2 lines in the image I am attaching here of the 15th October, is manual execution, why it didn't work? The 2nd question is why the log out is changing format?
To add to pan64's post
As far as I know the default format for the date command is "+%a %b %e %H:%M:%S %Z %Y" which is what you see when you manually run your script. The task scheduler is a front end for cron which uses a different environment then executing from the command line so just a wild guess the locale time format maybe changing between the two. I don't know what version of cron plasma is using which sets some environment variables or if the scheduler sets any environment variables itself.
My main concern ofcourse is why my script is not working regularly, the date format is not a real concern.
Here below is my script
Quote:
GNU nano 6.2 anajob.sh M
#!/bin/bash
#To wake up the external drive
#partprobe /media/alexe/Elements
#get day of week
dow=$(/usr/bin/date "+%a")
# convert DOW to lower case i.e. Mon to mon
ldow=${dow,,}
/usr/bin/rsync -a /home/alexe/afolders/ /media/alexe/Elements/$ldow/
astatus=$?
/usr/bin/rsync -a /home/alexe/Desktop /media/alexe/Elements/$ldow/
dstatus=$?
/usr/bin/rsync -a /home/alexe/afolders/ /media/alexe/Elements/$ldow/ 2>/path/to/error.log
...
echo "$(date) My stuff status=$astatus Desktop status=$dstatus" >> /path/to/status.log
Normally when you execute a program from the command line both stderr and stdout are written to the terminal. The stream number for stderr is 2.
I never execute this via command line. When I run the script manually, I do it via the GUI interface
System Settings->Startup and Shut Down->Task scheduler->Daily Backup
So, how will I chane the script?
Please note, in the current script i have two jobs, but for this exercise, I can skip the Desktop job.
#!/bin/bash
#To wake up the external drive
#partprobe /media/alexe/Elements
#get day of week
dow=$(/usr/bin/date "+%a")
# convert DOW to lower case i.e. Mon to mon
ldow=${dow,,}
/usr/bin/rsync -a /home/alexe/afolders/ /media/alexe/Elements/"$ldow"/ 2>/path/to/error.log
astatus=$?
/usr/bin/rsync -a /home/alexe/Desktop /media/alexe/Elements/"$ldow"/ 2>/path/to/error.log
dstatus=$?
if [ $astatus -eq 0 ]; then
echo "$(date) My_Stuff rsync completed successfully" >> /home/alexe/Desktop/dailyBackup
else
echo "$(date) My_Stuff rsync error $astatus" >> /home/alexe/Desktop/dailyBackup
fi
if [ $dstatus -eq 0 ]; then
echo "$(date) Desktop rsync completed successfully" >> /home/alexe/Desktop/dailyBackup
else
echo "$(date) Desktop rsync error $dstatus" >> /home/alexe/Desktop/dailyBackup
The problem is, that when the script does not run, there is NO output, just nothing happens.
This in my mind, means that something is wrong in my KDE setup, noothing wrong with the script itself.
Not much help there. Is your computer on 24/7 or is it on by 8:30 in the morning? cron jobs do not run if the computer is not running at the scheduled time. Otherwise you might want to consider using anacron instead. You can not select that exact runtime but it is guaranteed to run regardless of when the computer is turned on.
Not much help there. Is your computer on 24/7 or is it on by 8:30 in the morning? cron jobs do not run if the computer is not running at the scheduled time. Otherwise you might want to consider using anacron instead. You can not select that exact runtime but it is guaranteed to run regardless of when the computer is turned on.
The computer is ON 24/7 otherwise, how will any job run on it?
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.