Crontab in Linux shell using putty [closed] - linux

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
This may be very elementary but i am a a beginner when it comes to Linux shell.
I use putty to connect to the server.
I manage to login to the shell just fine. But there doesn't seem to be any option for running crontab commands.
Do i need to access any other file on the server first?
Like cd /var/spool/cron ?
I want to create a simple cronjob that starts a php file every 10 minutes today:
*/10 * 13 11 2 /PATH/mail.php
I'm blank, but it seems like i could do something like this to create a crontab file.
vi allcron
crontab allcron
When i do this i get to a new window. What to do here?
Thanks for any help!

You should use the crontab edit/list functions to add/remove your cron jobs.
crontab -e (to edit) opens an editor with the cron jobs. Simply add your statement or append if there are already cronjobs listed: */10 * 13 11 2 /PATH/mail.php
crontab -l to view your cronjobs.
See http://unixhelp.ed.ac.uk/CGI/man-cgi?crontab+5 for more info or type "man crontab" in your shell for the manual page.
Also note that your user must have privileges to manipulate cronjobs. Typically each user should have access to their own crontab for most cron daemons.

Related

BASH script to check if the linux server is "up" [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I want to create a BASH script to check if the Linux Web Server is "up" and run it automatically once every five minutes from the "internal" Linux Server and send an e-mail from from the script if a failure is detected.
Can someone please help me to make the script? Since i'm new to scripting.
If you want verify if a Web server is up and running, make a script to verify if exist a PID or process named with "apache" - Considering that you have web server Apache - this will show you not only if the machine is up and running but also if the webservice is working.
For a more professional tool, you can use Nagios.
Something like:
while sleep 60; do
if ! wget -o /dev/null www.example.com/; then
sendmail admin#example.com <<EOF
Subject: www.example.com is down
www.example.com is down, please do something.
.
EOF
fi
done

Where do I put cron commands? [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
I see a bunch of tutorials for cron commands like
0 */5 * * * /some_sript.sh
But what file do I put this line of text in?
From tag:crontab info
Basic commands
crontab -e Edit crontab.
crontab -l Show crontab current information.
Also, you'd better write
0 */5 * * * /bin/sh /some_sript.sh
instead of
0 */5 * * * /some_sript.sh
That is, indicate the binary executing the script.
You just need to run "crontab" command to edit the cron table. Try to "man crontab".

how to write and run a shell program on terminal without saving it first [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
I am working on a Linux server, I have access to a directory but I am not allowed to write anything to that directory. I can run commands from system prompt. Now I have to find values of specific field of some files in that dir and do some comparisons. I have a script on a test server can do that. But I can't install my script to the server, I am asking if there is anyway I type a specific command, then I can write and run a shell program without saving the program? Thank you!
If you have the script on another host, you can run it this way:
wget http://your.host.net/script -O- | sh -s
If the host is not accessible via HTTP, you can use any other protocol you want.
Also you can write a script direct in a shell:
sh -s <<EOF
echo Hello
echo I am script
echo Nice to meet you
EOF
You can use backtics to execute the result of another command.
`wget /path/to/your/script/stored/remotely -O-`
(you might use sftp to fetch the script instead)
Another option is to write a program that uses a tty to control an ssh session, then the script is stored on the ssh client but the commands run on the server. Perhaps the expect tool would help with that.

How to change Linux shell in a remote computer that does not support ypchsh [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
How do I change shell in a remote PC? I am logged into a cluster with a Bash and the output I see is
elan#l01:~ $ chsh
chsh: can only change local entries; use ypchsh instead.
elan#l01:~ $ ypchsh
-bash: ypchsh: command not found
Since I have no root privilege there, I can not install ypchsh in the cluster. Is there any other way to change shell without invoking ypchsh?
Note 1:
Browsing, it looks like another user who installed the same software (currently not available for questioning) has .cshrc in his directory, with the right settings. His .bashrc is minimal and has no redirections.
The /etc/passwd has no entry for either of us.
getent passwd
shows entry for both of us, but shows only /bin/bash for both.
Note 2:
The sofware has been developed with autotools, and using bash instead of tcsh is known to have created wrong builds. (I am not changing shell because I fancy it.)
Thank you,
Elan
In your .bashrc, put exec tcsh last.
Once you're in bash in the cluster, why don't you just type tcsh? And if that works, why not just add it as the last line of .bashrc?

Batch commands in linux, gnome, bash [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 11 years ago.
Improve this question
I am trying to make batch commands (sh) on linux for start, stop and restart my web server lighttpd, with partial success.
Ideally, I would like to doubleclick icon and nothing more to do a job.
Now, on doubleclick appear dialog "Do you want to run "START.sh", or display its contents?" and "START.sh" is an executable text file." with Run in terminal, Display, Cancel and Run buttons. Run in terminal do a job after typing password.
My script look as follows:
#! /bin/bash
sudo /bin/bash /etc/init.d/lighttpd start
echo
echo -n " [ENTER] to continue... "
read var_keypress
Is here any way for my script to run without prompted dialog and that I don't need to type password every time?
You can configure sudo to be usable with no password as described here:
http://www.linuxscrew.com/2008/06/22/configure-sudo-nopasswd/
Be sure to let sudo only run specific commands without password, not all.
You could avoid that with a system init script (ln -s /etc/init.d/lighttpd /etc/rc2.d/S99lighttpd on Debian) or with a crontab entry for #reboot

Resources