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.
If a cron job writes anything to stdout or stderr, cron has nowhere to put the output and will suspend the job (possibly including the stdout or stderr in the informative email, I'm not sure). Better
Code:
echo(bla bla bla Backup finished!) >> <some backup log file name>
EDIT:
The ( ) will cause bash to run bla as a command in a sub-shell. I should have suggested
Code:
echo 'bla bla bla Backup finished!' >> <some backup log file name>
There is not diference how I do the script. I can do it with c++ or bash command script language and double click on the file, execute and its runs?
And every script can be execute with crontab, right?
There is not diference how I do the script. I can do it with c++ or bash command script language and double click on the file, execute and its runs?
And every script can be execute with crontab, right?
"Script" is not precisely defined but is normally used to refer to interpreted languages including shellscript, awk and PERL. C++ is compiled into a binary executable.
Double clicking on a file suggests running it from a GUI file manager. I'm no expert on how file managers run files but it goes something like this.
The file manager looks at the first few bytes of the file. Scripts begin with #!<language processor file name> <arguments>. In that case the file manager starts the language processor (for example bash) and lets it execute the script. In other cases, the file manager reads a "magic number" from the file which tells it what sort of file it is. In the case of a binary executable the file manager starts a process running the file. In the case of something else, such as a JPEG, the file manager starts the appropriate program and lets it do whatever with the file.
The *n*x "type" command does something similar to the file manager but displays the information in human readable form.
is wrong. Do not leave a space between '#!' and '/bin/bash'
Also, Perl isn't interpreted, it's 'compiled on the fly', so its about 80% or 90% as quick as C, all other things being equal. http://www.perl.com/doc/FMTEYEWTK/comp-vs-interp.html
is wrong. Do not leave a space between '#!' and '/bin/bash'
Also, Perl isn't interpreted, it's 'compiled on the fly', so its about 80% or 90% as quick as C, all other things being equal. http://www.perl.com/doc/FMTEYEWTK/comp-vs-interp.html
So, I have to write my scripts only with bash program language?
And If I write some script with c++ or Perl, then it must be compiled and then execute it, right?
So, I have to write my scripts only with bash program language?
And If I write some script with c++ or Perl, then it must be compiled and then execute it, right?
C++ must be compiled. You can treat PERL as if it were a script; the PERL executable compiles the script before executing it.
is wrong. Do not leave a space between '#!' and '/bin/bash'
Thanks for the "heads up", chrism01. According to the GNU Bash Reference, section Shell Scripts, the space should be present. I routinely do not use the space, in line with your comment. I guess it is optional. Do you know how to test it? In other words, is there any way from within a running bash script to determine what the value of <path-to-shell> was in #!<path-to-shell>. I think there is a way but I cannot find 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.