Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
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.
Update: It seems that my mistake was using sudo -s and then crontab -e, when I did it without sudo permission it worked. But not completely, I am still unable to save it in /home/odroid/kodibackup , instead it saves it to /home/odroid. Also how can I make it so that when first one is done, the second one will show up as kodi-bakup.tar.gz.1, kodi-bakup.tar.gz.2. and so forth.
Last edited by tuxthegreat; 07-20-2021 at 06:09 AM.
Indeed. The other benefit is with a script you can test it, not wait for cron to run and fine out then. The script can be activated endlessly as you adjust and tinker. Of course the same could be said that you can make the script, then just copy the line into the crontab I suppose once it works. Don't forget about potential PATH issues though. Cron doesn't have the normal PATH by default.
Looking at your entry that may be the issue actually.... PATH isn't set. Try full path to tar.
What did you think was best here? I agree with petelq and jmgibson1981, about putting the complex statements in a script and executing it. What would you have done??
Now i guess that i am going to do as jmgibson1981 said, i just can't find any other solution, maybe you can share some new advice???
Perhaps if you opened your own thread, and provided your own details and asked your own question, we can. You just thanked folks for 'sharing their thoughts'....I asked what, in particular, you found helpful.
Ok guys calm down, were all friends here OK I like this script idea, it's clean and can be adjusted to my liking, only problem is I don't know how to write a script. But I don't want to give up, I can try to do this with your help. Let's see what I want done, first task is this
Code:
tar -czf kodi-bakup.tar.gz ~/.kodi
then I want to put the resulting tar.gz package into a directory here
Code:
/home/odroid/kodibackup
and third I want this to happen once a week, anytime really, my server runs 24/7. So what can we do guys, let's put on our thinking caps on.
Last edited by tuxthegreat; 07-20-2021 at 04:19 PM.
Ok guys calm down, were all friends here OK I like this script idea, it's clean and can be adjusted to my liking, only problem is I don't know how to write a script.
Sure you do...a script, in its most basic form, is just a list of commands you can type in on the command line. Put them in a file, and make the file executable (chmod 755 <filename>).
So your tar command, and whatever else you want can go into "/path/to/your/filename". That's it...the commands in that file will run one by one. If they run on the command line, they'll run in the script. An important note, though, for both scripting and cron jobs...specify the full paths to executables. Don't just put 'tar', put "/usr/bin/tar", and the like.
Granted, scripts can have loops, variables, etc., etc., but in your case, you just want one command.
Quote:
But I don't want to give up, I can try to do this with your help. Let's see what I want done, first task is this
Code:
tar -czf kodi-bakup.tar.gz ~/.kodi
then I want to put the resulting tar.gz package into a directory here
Code:
/home/odroid/kodibackup
and third I want this to happen once a week, anytime really, my server runs 24/7. So what can we do guys, let's put on our thinking caps on.
Have you checked any of the MANY thousands of bash tutorials, since you say you can't write a script?? There's even one in my posting signature...write your script, and put it in cron.
Lots of cron examples and tutorials...have you referenced any?? Simple cron explanation:
Code:
cron field explanation...suitable for inclusion in your crontab file
# * * * * * command to be executed
# - - - - -
# | | | | |
# | | | | +----- day of week (0 - 6) (Sunday=0)
# | | | +------- month (1 - 12)
# | | +--------- day of month (1 - 31)
# | +----------- hour (0 - 23)
# +------------- min (0 - 59)
Sure you do...a script, in its most basic form, is just a list of commands you can type in on the command line. Put them in a file, and make the file executable (chmod 755 <filename>).
So your tar command, and whatever else you want can go into "/path/to/your/filename". That's it...the commands in that file will run one by one. If they run on the command line, they'll run in the script. An important note, though, for both scripting and cron jobs...specify the full paths to executables. Don't just put 'tar', put "/usr/bin/tar", and the like.
Granted, scripts can have loops, variables, etc., etc., but in your case, you just want one command.
Have you checked any of the MANY thousands of bash tutorials, since you say you can't write a script?? There's even one in my posting signature...write your script, and put it in cron.
Lots of cron examples and tutorials...have you referenced any?? Simple cron explanation:
Code:
cron field explanation...suitable for inclusion in your crontab file
# * * * * * command to be executed
# - - - - -
# | | | | |
# | | | | +----- day of week (0 - 6) (Sunday=0)
# | | | +------- month (1 - 12)
# | | +--------- day of month (1 - 31)
# | +----------- hour (0 - 23)
# +------------- min (0 - 59)
The link on your bash is causing a "The page isn’t redirecting properly"
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.