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!
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.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
I am new in Shell Scripts, Perl and Cron Jobs. Presently i am downloading around 600 MB files from ftp server manually in every monday. This is affecting our internet bandwidth during office hours. For avioding this, i am planning to schedule cron jobs at every monday morning 3 AM for download process.
Download Process to be performed in SUSE Linux. Becoz Downloaded files to be replaced into that server only.
My R&D description is,
1) I have to stop my server first. I have given below scripts for stop server process
login as endeca
a)endeca# . .endeca_apt
b)endeca# cd bin/
c)endeca/bin# RunCommand apt_control.script apt_stop
a)endeca# . .endeca_auto
b)endeca# cd bin/
c)endeca/bin# RunCommand auto_control.script auto_stop
a)endeca# . .endeca_chrome
b)endeca# cd bin/
c)endeca/bin# RunCommand chrome_control.script chrome_stop
a)endeca# . .endeca_babe
b)endeca# cd bin/
c)endeca/bin# RunCommand babe_control.script babe_stop
How can i write scripts with should be stopped my server process in differnt user?
2) I have to download files from four source folders Like /Source/Dumps1/*, /Source/Dumps2/*, /Source/Dumps2/*, /Source/Dumps2/*. Download scripts will be run in root user only?
FTP Host is 10.10.10.100 port 21
3) Downloaded files are replaced into my Destination folder like /space/endeca/apt/, /space/endeca/auto/, /space/endeca/chrome/, /space/endeca/babe/ - This will possible on root user only. Is there need to delete the old files in that four folders?
4) Once Files are moved into destination path. I have to change the ownership of that files like below
Hope my thread is getting boring to read it. Now i tried to write a shell script for my R&D and scheduled it through cron jobs. Below my code...
ftp -in 10.10.10.100<<END_SCRIPT
quote USER abc
quote PASS abcded
I have scheduled last night 2 AM for my download process. Here below crontab entries....
00 02 * * 2 /root/ftp.sh > /root/ftp.log 2>&1
But only 3 files copied to /home/endeca/chrome/ location.
I have pasted my ftp.log entries for your reference. Please help me to fix it.
ftp -in 126.96.36.199<<END_SCRIPT
+ ftp -in 188.8.131.52
Interactive mode off.
Local directory now /home/endeca/chrome
'EPSV': command not understood
What you need to do is put all those cmds in a shell script (in the correct order).
Make sure that you call ('source') and additional env vars you need at the top.
Also, remember that cron has almost no default env eg PATH, so always specify the complete path to any prog (inc any called from within your shell script) or binary you use.
Here's an example
16 22 * * * /bin/su -c /home/chris/t.sh - chris
means at 16:22 switch to the user 'chris' and run the cmd 'home/chris/t.pl' as him (from the main ie root crontab)
Of course, normally you'd try to avoid hardcoding user/passwd in a script, but if you run the script as root itself ie
I have to download four folder files from ftp. so that i wrote scripts for that. Also I have scheduled in root user only. my shell scripts also available in root folder. Offcourse you could notify that.
>00 02 * * 2 /root/ftp.sh > /root/ftp.log 2>&1
Every Tuesday morning 2 AM cron jobs will do the download process.
>means at 16:22 switch to the user 'chris' and run the >cmd 'home/chris/t.pl' as him (from the main ie root crontab)
>Of course, normally you'd try to avoid hardcoding user/passwd in a >script, but if you run the script as root itself ie
>16 22 * * * /root/t.sh
Yes chris, My script running in root user.How can i hardcode my user/password of ftp?
>What you need to do is put all those cmds in a shell script (in the >correct order).Make sure that you call ('source') and additional >env vars you need at the top. Also, remember that cron has almost >no default env eg PATH, so always specify the complete path to any >prog (inc any called from within your shell script) or binary you >use.Here's an example
Would you please explain in detail.
Re cron env:
In a normal user acct do
do the same in root, you'll prob see a few differences.
PATH is where the shell stores a list of default dirs to search for a cmd (in order). If you just say eg
as a normal user, you'll get
bash: ifconfig: command not found
This is because the absolute path to ifconfig (/sbin) is not in your path.
You can access it as
as root, because root's $PATH does include /sbin.
The env in cron is even more minimal, so always specify the complete/absolute path eg
for all progs/cmds (unless it's a shell built-in).
so, for a start, don't say
and so on.
PS You can check what the default env in cron is by just writing a one-liner to run in cron to do
or (just for PATH)
echo $PATH >/root/env.txt