how to set destination directory in crontab, with cpanel - cron

I want to use cron to download and unzip then move to direcotry in my server,
what i did:
wget http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz -
|gunzip GeoLiteCity.dat.gz &&
mv GeoLiteCity.dat 37.18.176.133/~work/wp-content/plugins/shabatkeeper/GeoLiteCity.dat
what i get:
--2014-12-22 11:00:03--
http://-/ Resolving -... failed: Name or service not known.
wget: unable to resolve host address `-'
FINISHED --2014-12-22 11:00:03--
Downloaded: 1 files, 11M in 1.1s (10.7 MB/s)
how to set destination directory?
Answer - what id did:
downloaded the file with
wget http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz
entered cpanel file browser and check where the file GeoLiteCity.dat.gz is.
3.then saw which directory was home and how its called and found the the path i needed is
/home/work/www/
that's it

This should do what you're looking for
wget -q -O- http://geolite.maxmind.com/wnload/geoip/database/GeoLiteCity.dat.gz | gunzip > /path/to/where/you/want/GeoLiteCity.dat

Related

Rsync to Amazon Linux EC2 instance - failed: No such file or directory

I want to upload the content of one directory to my Amazon EC2 with rsync:
rsync -r -t -v --progress -z -s -e "ssh -i /home/mostafa/keyamazon.pem" /home/mostafa/splitfiles ubuntu#ec2-64-274-161-87.compute-1.amazonaws.com:~/splitfiles
but I receive the following error message:
sending incremental file list
rsync: link_stat "/home/mostafa/splitfiles" failed: No such file or directory (2)
rsync: change_dir#3 "/home/ubuntu//~" failed: No such file or directory (2)
rsync error: errors selecting input/output files, dirs (code 3) at main.c(712) [Receiver=3.1.0]
and if I do a dry run with grsync, it works correctly
In rsync the trailing / is very important. Also you rsync usually defaults to ssh when one of the destinations contains a host.
So you if you want to preserver modification times then you can get rid of the -e and -s options.
Your command could be written as /home/mostafa/splitfiles/ ubuntu#ec2-64-274-161-87.compute-1.amazonaws.com:splitfiles/ - notice the trailing /'s provided that you have ssh configured to read the private key from your home directory.
On ubuntu you can add this to the key chain, by going
ssh-add [key-file]
And this will save you having to specify the keyfile everytime you ssh into the AWS machine.
The errors seem to say that on the local machine you don't have a source directory and the destination doesn't exist.
I completed this task with Filezilla instead, easier to use.
You are at home ~ if you cd ../ to root you will be able to run the command.

Why this file do not get downloaded into a specified location?

I am downloading the file in this link. I am using Ubuntu 12.04 and I used the below command to download it.
wget -p /home/ubuadmin/CUDA http://developer.download.nvidia.com/compute/cuda/5_5/rel/installers/cuda_5.5.22_linux_32.run
Below is my command line input and output.
root#ubuserver3:/home/ubuadmin# wget -p /home/ubuadmin/CUDA http://developer.download.nvidia.com/compute/cuda/5_5/rel/installers/cuda_5.5.22_linux_32.run
/home/ubuadmin/CUDA: Scheme missing.
--2014-03-11 08:06:28-- http://developer.download.nvidia.com/compute/cuda/5_5/rel/installers/cuda_5.5.22_linux_32.run
Resolving developer.download.nvidia.com (developer.download.nvidia.com)... 23.62.239.35, 23.62.239.27
Connecting to developer.download.nvidia.com (developer.download.nvidia.com)|23.62.239.35|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 686412076 (655M) [application/octet-stream]
Saving to: `developer.download.nvidia.com/compute/cuda/5_5/rel/installers/cuda_5.5.22_linux_32.run'
100%[======================================>] 686,412,076 663K/s in 16m 56s
2014-03-11 08:23:24 (660 KB/s) - `developer.download.nvidia.com/compute/cuda/5_5/rel/installers/cuda_5.5.22_linux_32.run' saved [686412076/686412076]
FINISHED --2014-03-11 08:23:24--
Total wall clock time: 16m 56s
Downloaded: 1 files, 655M in 16m 56s (660 KB/s)
It says the download is completed but I can't find the file in that folder. I am accessing this server remotely using PuTTY, and using WinSCP to see the file structure. What has gone wrong? Why is it missing even it is downloaded?
To set the target folder, use -P (upper case) instead of -p.
From man wget:
-P prefix
--directory-prefix=prefix
Set directory prefix to prefix. The directory prefix is the directory
where all other files and subdirectories will be saved to, i.e. the
top of the retrieval tree. The default is . (the current directory).
cd /home/ubuadmin
mkdir test
cd test
wget http://developer.download.nvidia.com/compute/cuda/5_5/rel/installers/cuda_5.5.22_linux_32.run
after use this command
stat cuda_5.5.22_linux_32.run
and show output
The "p" needs to be capitalized. Keep in mind Linux is case sensitive in most aspects.

Cannot build Mercurial from sources in CentOS

I'm trying to build Mercurial on CentOS 6, so here is what I've done so far:
I got mercurial's latest sources, file is named mercurial-2.4.1.tar.gz
I try running rpmbuild on it and I get the following:
# rpmbuild -tb mercurial-2.4.1.tar.gz
error: File /home/someuser/rpms/mercurial/mercurial-snapshot.tar.gz: No such file or directory
So I try creating the file that it wants by copying from the other guy:
# cp mercurial-2.4.1.tar.gz mercurial-snapshot.tar.gz
I try again, appears to pass the previous error:
# rpmbuild -tb mercurial-2.4.1.tar.gz
Executing(%prep): /bin/sh -e /var/tmp/rpm-tmp.vV9ZXc
+ umask 022
+ cd /root/rpmbuild/BUILD
+ cd /root/rpmbuild/BUILD
+ rm -rf mercurial-snapshot
+ /usr/bin/gzip -dc /home/someuser/rpms/mercurial/mercurial-snapshot.tar.gz
+ /bin/tar -xf -
+ STATUS=0
+ '[' 0 -ne 0 ']'
+ cd mercurial-snapshot
/var/tmp/rpm-tmp.vV9ZXc: line 34: cd: mercurial-snapshot: No such file or directory
error: Bad exit status from /var/tmp/rpm-tmp.vV9ZXc (%prep)
RPM build errors:
Bad exit status from /var/tmp/rpm-tmp.vV9ZXc (%prep)
I'm not sure what is happening, my guess is that rpmbuild is not being able to create files... any ideas?
The easiest way I have found to build an RPM for CentOS that isn't already available is to find a source RPM from Fedora and do rpmbuild --rebuild on it. CentOS documents it here but seems to be down right now.
Here is a src RPM you can give a try to start with.
You don't have a /var/tmp/ directory or can't write to it. Try creating it: mkdir /var/tmp - you may have to use "sudo" for this to work, depending on the setup of your system.
I think that creating tarball by cp command is not good.
You should rename the mercurial-[version]/ directory generated after extracting the official tarball to mercuial-snapshot/ and then create zipped tar archive of the directory named mercurial-snapshot.tar.gz.
$ tar zxvf mercurial-2.4.1.tar.gz
$ mv mercurial-2.4.1 mercurial-snapshot
$ tar zcvf mercurial-snapshot.tar.gz mercurial-snapshot
The issue is that the bundled spec file has a version default of "snapshot", so it's going to look for a tar file named "mercurial-snapshot.tar.gz", and also expects the extracted directory to be "mercurial-snapshot" (so you can't just rename the tar file).
The best way (or at least, a way) to handle this is to extract the spec file, update it with the correct version and release number, then build the rpm from that.
Here's the process:
tar fxz mercurial-X.Y.tar.gz --strip-components=2 mercurial-X.Y/contrib/mercurial.spec
Place the spec file in rpmbuild/SPECS and edit it. Replace the "Version: snapshot" line with "Version: X.Y", and replace the "Release: 0" line with "Release: 1.xyz" where xyz is a custom tag so you know that you built the package yourself.
Then run rpmbuild:
rpmbuild -bb --target=i686 SPECS/mercurial.spec
Use --target=x86_64 if you're on and building for a 64-bit system.
You should then have a correctly built and named rpm file in the RPMS/$target directory.

How to downlaod a file in a directory using wget command in bash script?

I want to download a list of files using "wget" command of linux in a bash script file. The problem is that when I am trying to change the directory to another subdirectory in my home, it does not work and the wget after the cd command will download the files in my home directory not the desired subdirectory
mkdir -m 777 "dbback2012"
cd "dbback2012"
wget -r [FTP URL]
The problem is that the downloaded files via wget are in the home directory not the "dbback2012" directory.
There's nothing wrong with the code, you either
haven't shown us the real code
the script is executed somewhere else, check the working directory: pwd
the script failed to create the directory mkdir -m 777 "dbback2012" || (echo "ooops"; exit 1)

Howto created trimmed directory tree while using wget for ftp download

Am using wget for download files from ftp.
Ftp folder have name /var/www/html/
Inside this folder is located tree of folders & files, ~20 levels.
Am trying make ftp download (have no ssh access), of this all with wget.
wget -- recursive -nv --user user --password pass ftp://site.tld/var/www/folder/
This one command runs Ok. But it creates an folder structure.
~/back/site.tld/var/www/html/my-files-and-folders-here
Question:
Is any possibility - to say wget, not create ~/site.tld/var/www/html/ but make all tree, in current folder?
i.e. ~/back/my-files-want-here/ I.e. - to trim/cut certain path?
Thanks
Look for --no-host-directories and --cut-dirs in the manpage.
This should work like expected (maybe you have to increase/decrease cut-dirs):
wget --recursive --no-verbose --no-host-directories --cut-dirs=3 --user user --password password ftp://site.tld/var/folder

Resources