Server :: Used The Command Crontab To Load The Table But Didn't See Any Execution Of The Script?
Jan 27, 2010I created a file which in I tried both :
Code:
MAILTO=""
* * * * * /var/www/scripts/script.php >> /dev/null
[code]....
I created a file which in I tried both :
Code:
MAILTO=""
* * * * * /var/www/scripts/script.php >> /dev/null
[code]....
I have a tiny shell script to rsync files between two servers and remove the source files.
This script works fine, when it has been initiated manually or even when the rsync command is executed on the command line.
But the same script doesn't work, when I try to automate it through crontab.
I am using 'abc' user to execute this rsync, instead of root, as root login to servers are restricted in all of our servers, by us.
As I mentioned earlier, manual execution works like charm!
When this rsync.sh is initiated through crontab, it runs the first command(chown abc.abc ...) perfectly without any issues. But the second line is not at all executed, and there is no log entry i can find at /mnt/xyz/folder/rsync.log.
For some reason crontab does not work on my system.
Fedora Core 11
I am running from a Virtual Private Server.
Code:
Code:
Having an odd problem running a mysqldump via crontab. I have the script running on other servers and they work fine, so not sure how to actually troubleshoot, but the script looks like the following;
If I run it as a cronjob as root, it finishes in a second and a 20k file is there. If I run it from the command line as root it does the backup (takes a few minutes) but does complete the backup and can be unzipped and read successfully.
Script iptables_reset.sh
Code:
#!/bin/bash
IPTABLES="$(which iptables)"
$IPTABLES -P INPUT ACCEPT
$IPTABLES -P FORWARD ACCEPT
[code]....
This works if I edit the system-wide crontab in /etc/crontab like this:
Code:
0 12 * * * root /root/iptables/iptables_reset.sh
But it won't work, if i edit roots user-cronfile by using crontab(1):
Code:
crontab -l
# m h dom mon dow command
0 12 * * * /root/iptables/iptables_reset.sh
The log entry is the same for system-wide and user-cronfile:
Code:
/USR/SBIN/CRON[5135]: (root) CMD (/root/iptables/iptables_reset.sh)
I tried different things and found out,if i don't use the "$(which iptables)"substitution in the script, it also works with the user-cronfile.
I have a question about using crontab with /etc/crontab...
I had a cron job that I needed to run as root. At the time I thought that sticking it in /etc/crontab would be a good idea. However, I used the crontab command to edit /etc/crontab, which I guess is not standard procedure? Specifically, I configured /etc/crontab as my local user's crontab (i.e. sudo crontab /etc/crontab) then added my cron job as I would a local user crontab (i.e. sudo crontab -e).
Originally, my cron job looked like this:
30 * * * * root /my/batch/script &> /dev/null
After adding the new cron job I started seeing errors. Something to the effect of "can't find command root" or something similar. So I removed the 'root' user definition from the cron job and the job started running fine. However, because this is /etc/crontab, there are other system related cron jobs that have been defined to run under the root account (e.g. "17 * * * * root cd / && run-parts --report /etc/cron.hourly" runs as root, etc.). So these pre-existing system cron jobs, which up until now have been running smoothly, are now generating "can't find command root" errors. But I think that the system cron jobs _are_ successfully being run someplace because logrotate seems to be working.
So what I _think_ is happening is that /etc/crontab is being run twice: once as the system crontab, and once as my sudoed local user's crontab. When I run crontab -l I see nothing, but when I run sudo crontab -l I can see the contents of /etc/crontab. I am reluctant to delete my sudoed local user's crontab, because then in the process I would be deleting the system crontab, and I do not know how I should restore the system crontab's contents. (I am still not sure as to the most appropriate way to edit the system crontab).
How can I get out of this mess? I want /etc/crontab to go back to the way it was before--running _once_ as the system crontab. As for my new cron job, I'm willing to reconfigure it anywhere so long as I am still able to run it as root. Any ideas? (I am using Ubuntu 8.04 Server LTE)
Bash's command history is great, especially it is useful when adding the history -a command to the COMMAND_PROMPT.However, I'm wondering if there is a way to log the commands to a file as soon as the Return key is pressed, e.g. before starting the command and not on completion of the command (using the COMMAND_PROMPT option would save the command once the prompt is there again).
I read about auditing programs like snoopy and session recorder like script but I thought they're already too complex for the simple question I have. I guess that deactivating that script logs all the output of the command would lead already in the right direction but isn't there a quicker way to solve that probelm?
is there any way to decrease the cpu load during qemu execution?
View 5 Replies View RelatedUp until now I've been using plink to remotely compile a project I'm working on. But recently the administrator from the remote server updated the distribution and messed up some configurations. My project has a lot of scripts written for tc shell (tcsh), and now the default shell is bash. There is no way to change this. Another problem is that now I need to run newgrp to change my default user group.
So... to work around this problem I've changed my .bashrc to run newgrp and then tcsh. If I do a normal connection using SSH, everything works as expected, but when using plink, or SSH to remotely execute commands, the shell gets stuck on the newgrp command. I think it's because both applications need a return value from newgrp to send the command I need to execute. Remotely running scripts that call a shell also get stuck like newgrp (newgrp also opens a new shell and that's why it gets stuck) my .bashrc is as follows:
Code:
user_grp=`id -g`
if [ $user_grp != 4919 ]; then
newgrp new_group_id
else
[code]....
I have a script which builds a project and then runs junit tests. However, if the build fails, the junit tests fail with the same error message.Therefore the command which runs the junit tests should only be executed if the build was successful.
View 3 Replies View RelatedI've never liked unity much so I've been using classic. However, out of curiosity I decided to give it a try. However, when I tried to load it, my login sound played, but the dock and the taskbar didn't load. I've been using compiz in classic, so would that have anything to do with it?
View 9 Replies View RelatedI am using Linux 64 bit Redhat Linux. I am trying to setup simple crontab as follow...1. Edited crontab file using crontab -e2. Listed the file once to verify it using crontab -l. This will display as.. 18 5 * * 2-3 ksh $HOME/testScript.sh > $HOME/testscript.out3. Logged in a root and restarted cron deamon using "/etc/init.d/crond restart"As per my understanding now my testScript should start running at 5:18 am Thuesday
View 3 Replies View RelatedI have seen command like $rm aa dd cc bb ee then something like $ >> zz // it removes zz also Where aa dd cc bb ee zz are the files in my directory. Do not know exactly.
View 6 Replies View RelatedProblem started after installing a new firewall in my network. originally after installing the firewall there would be a 10 second delay after entering a command before it was processed, the command would be executed however there would be an error, i forget what it said, something about not being able to resolve my domain name (and it would give my domain name). i realized this was a problem with my NAT, so i configured DNS forwarding on my firewall so that any attempt to access my server using my domain name from inside the network would point back at my server. after setting up the DNS forwarding i no longer receive the error about my domain name being unreachable, however there is approximately a 30s delay between entering a command and its execution.
the problem is hardly critical i do not see any more serious problems, it is just a pain to do any work when every time i try to do something i have to wait for it to execute.
How do I create a command to launch a program and then have the terminal wait for a specified time and then move on to the next command?I'm wanting to create a startup script, and I need program B to wait until program A has finished loading up.
View 2 Replies View RelatedI have the following command:
Code:
(systool -c fc_host -v && systool -c fc_remote_ports -v) | grep -E '+Class Device path = "/sys/class/fc_host/host[0-9]+"$|+node_name.*= "0x[0-9a-f]{16}"$|+Class Device path = "/sys/class/fc_remote_ports/rport-[0-9]+:[0-9]+-[0-9]+"' | sed -e 's#.*host([0-9]*).*"#scsi-qla1-adapter-node=#' -e 's#.*rport-([0-9]*):[0-9]*-([0-9]*).*#scsi-qla1-target-2=#' -e '$!N;s#
##' -e 's#=.*node_name.*= "0x#=#g' -e 's#"$#;#g' | sort
and I want it to execute via ssh on a remote machine through a script. Therefor I need to escape it properly. Because of the massive use of regular expressions and commandline options, this is not an easy task. Is there any (online) utility that will escape that for bash use? I suppose pasting the code in vi and doing some search and replaces should do the trick. But for that I would need a list of characters to escape...
I'm not quite sure what's up with this, but when I change the title of a terminal away from the default (e.g. to represent which project that terminal is to be used for), it changes back to the default (user@host:path), but only on the task bar at the bottom of the screen, listing the open windows.
If I change tabs in the terminal and then change back, it displays again at the bottom of the screen, but as soon as I execute another command (e.g. ls), then it resets again. That's quite annoying, as I like to have a few terminals open, each with a set of tabs pertaining to a particular project. The fact that I can't see from the title on the taskbar which is which means I have to guess/remember/check them all...
I have a script:
Quote:
# Call mail script to send an email
if [ -f /tmp/report.txt ]; then
/usr/local/scripts/mail.pl
sleep 10
rm /tmp/report.txt
else
exit
fi
What I need to do is, I want to check if file exists, if file exists call other script (mail.pl) and then delete the file (assuming mail.pl script executed). If file not exists just exit out of the script. I'm not sure how I can see that other script execution completed or not before I delete the file even though I put sleep command. And also it seems like its not that good, even though it is working. I wanted to see if we can write in more efficient way.
I recently installed Suse 11.1 from the Live CD on an older PC. Suddenly, when booting up yesterday, the system announced corrupted IPtables and didn't load KDE. After login, I tried commands like KDE, run KDE but the bash didn't understand the commands.
So I booted from the live CD, but I can't find an option in the install menu to repair the existing installation. The help in the boot-up screen claims there should be an install option, but it doesn't show it at that point, only after KDE has started from the Live CD.
Since I've already made some changes (newer firefox, downloaded thunderbird etc.), I would like to keep and repair the current installation, instead of a new installation.
I don't however understand enough about the automatic partitions I'm being offered in the installation menu to know what to choose to keep the existing files. I did choose the offered automatic partitions the first time, and have now several partitions, home swap and so on.
Second question: While 11.1 was still running nicely, I could not find the option to upgrade to 11.2 in the Yast menu (I don't know any batch commands, so I only use Yast for installation). Looking at the download sites on opensuse on the internet, I saw an update option, but when I tried to add that URL to the Yast repository, it somehow didn't work. I also didn't see a nicely packed .rpm or similar update package.
Third problem: I downloaded a newer version of Firefox and Thunderbird and after some tries got Yast software repositories to install them. But the Avira antivir tar.gz package I downloaded, did not appear on the Yast repository manager. Doubleclicking to Ark didn't work, and when I went to console and tried to run the install file in the zipped package, it wanted parameters, and I didn't know what to answer.
I want to use ssh to execute a command and to wait endlessly to log everything (in file) that comes as a stream of the connected server. But unfortunately, in the manual its written "If command is specified, it is executed on the remote host instead of a login shell"
So what happens is that when I specify my command:
ssh user@server "my_command"
It executed the command and the flow of execution returns to bash shell. So basically my session ends right after the command is executed. This happens only in case I specify command in the command line. If I login into ssh manually and then type "my_command", then the session doesn't end. I want the ssh not to exit, because after "my_command" executes, I want to capture everything in the session.
I am attempting to write a very basic script that monitors a server's load and automatically emails an administrator upon the load reaching a certain threshold...
1.) `uptime | awk -F ' ' {'print $10'} | cut -d ',' -f1 | awk -F '.' {'print $1'}` -- the output from this command results in a decimal figure, so when that value is parsed and placed in an if statement, the value is not seen as a number. load-monitor.sh: line 9: [: 4.96: integer expression expected/How can I allow a number like "4.56" to be seen as an actual number within the if statement and be compared to 4, for instance?
2.) I am running a cPanel server on CentOS 5.4 -- when I run mail -s "SUBJECT" $EMAILADDRESS the command just hangs, and stracing the process shows it stuck on a read syscall.
3.) If I wanted to write this script in PHP, I have one primary confusion -- how can I mimic the functionality of obtaining the output from uptime via awk, etc. so that I can determine what the server load is at a given time? Which PHP function(s) would assist in that regard?
I write a little script that run top command and clear the output leaving only cpu ram and swap values. If i run the script manually everityng works fine but when i schedule the cript to run every 5 minutes from /etc/crontab all run fine but the output of the top command doesnt appear in the log :
This is the cript :
#!/bin/sh
echo "#############################" >> /var/log/performance.log
echo "" >> /var/log/performance.log
/bin/date >> /var/log/performance.log
[code]...
I tried scheduling a task using crontab -e and added the line:
Code:
58 23 3 2 4 /usr/bin/freshclam --verbose --log=/home/EXISTING DIR where I have permissions
The timing was simply a test run. My syslog gives the following error:
Code:
(CRON) error (grandchild #4309 failed with exit status 62).
I also tried to add to root crontab as below, but got the same error.
Code:
sudo crontab -u root -e a
I am scheduling a command for a specific time every day.
Linux crontab format which I am using :- MIN HOUR DOM MON DOW CMD
30 08 10 06 * /home/mach/script.sh
Some presetting is required?
How to break strings of command into multi-lines in crontab? e.g.
Code:
# the following is a very long a gruesome command to be run at 09:59 Monday to Friday.
59 09 * * 1-5 source $HOME/some-definitions; sh /usr/local/my/long/name/application/bin/hello $(date +\%Y\%m\%d) >>/var/log/my/long/name/application/log/hello.log
I have install RHEL5 and created normal user as "test". When I login as root user, I can run crontab command but when I login as test user, I can't run crontab command and throws error as "cron/test: Permission denied". how to enable crontab command for test user as well?
View 3 Replies View RelatedSomeone/one or more internal process is executing script and running those under login apache. These scripts are being uploaded under /tmp, I've stopped executing under /tmp but that person or process is now calling directly calling apache to execute those script. Here are the logs of /var/log/httpd/error_log file
Code:
--02:58:21-- ftp://coreyrudlprod:*password*@72.167.232.36/a.pl
=> `a.pl'
Connecting to 72.167.232.36:21... connected.
Logging in as coreyrudlprod ... Logged in!
==> SYST ... done. ==> PWD ... done.
[Code].....
I just recently installed ubuntu server. I want to be able to install packages and such but can't until I connect to Internet. I tried wifi but couldn't figure out how (I'm a n00b) but now I have ethernet and can't figure out how to make it work. So my question is, how do I connect to my Ethernet with ubuntu server, I could if I had graphical, but I can't get that until I have Internet. I didn't configure network during install, so how do I do it now?
View 3 Replies View Relatedis it possible disabling a crontab job without deleting the crontab description entry (by crontab -e)?I could also accept to change the entry itself. Now it's:0 0 * * 0-6 /home/me/cron/script.csh
View 4 Replies View RelatedI am outstation and having laptop with windows and internet connection. I want to check one small program on linux. kindly tell if some free linux server is available on internet where I can upload my program, compile and execute. The program is generic and there is no restrictions regarding linux version.
View 2 Replies View Related