Tag Info

New answers tagged

0

Directories like /usr/local/bin and /usr/local/sbin are not by default in cronjobs $PATH. But you can redefine $PATH in crontab, simply put something like this before any defined cronjobs PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin


0

The $PATH environment variable under cron is limited, and will include neither /usr/local/bin nor /home/foobar/dir. The correct answer is, as you found, to fully qualify the path to the script in your crontab; it leads to less surprises.


0

$HOSTNAME is set by some shells (like bash), it is not an environment variable Set your shell script to run under bash (put #!/bin/bash as the first line instead of #!/bin/sh) and try again


0

Make sure your script is executable chmod +x yourscript.sh


1

You should not rely on MySQL client to pick up the appropriate MySQL configuration file because of the cascading nature of how the client is reading those files. Instead you should put both your my.cnf and test_mysql.sh inside /home/tmp and use --defaults-extra-file [link] parameter in your script. Do take note, the --defaults-extra-file needs to be the ...


0

You can do this directly with cron: # Run every 2nd Wednesday at noon # Minute: 0 # Hour: 12 # Day of month: 8-14 (2nd week, in other words) # Month: any # Day of week: Wednesday (3) 0 12 8-14 * 3 echo '2nd Wednesday'


0

I realize that this is straying from the original question, but it is staying on the theme of efficiency (you mention "huge strains on my server")... I'm inferring (or guessing!) from what you've posted that you are creating a tar containing a set of files and then gzip-ing the result. You could save yourself a lot of disk I/O (and temporary space ...


3

The following should work: 58 12 * * * (cd /home/joe/dev; echo `pwd` | logger) By wrapping the commands in parentheses, you should force them all to run in the same subshell.


3

As per this Unix&Linux SE answer, you can replace ; with && as different versions of cron across different Linux distributions handle this type of functionality in different ways: cd /home/joe/dev && echo `pwd` | logger


6

The commands are being run independently, so it is not the same as expecting them to run in the same shell/environment. You would probably be better served by creating a shell script that performs the desired commands and then calling the script from the crontab. Update: The above was a guess, and/or proposed possibilty (as a comment so tersely and ...


1

The % in your crontab file gets turned into a newline character unless escaped with a backslash. Try grep `date +\%Y-\%m-\%d` /var/wwww/file/file.log >> /home/filename/file.log see man 5 crontab for details.


0

it turned out that my system was messed up by selinux because I symlinked /var to another parition and selinux has permission issue with it. I had to grant permission 777 to the symlink /var(not the data). and then everything works.


0

You could try running the csf command with full path. /usr/sbin/csf As far as I know csf does not implement any kind of queuing when running csf -d so blocking too many IPs really quick will cause load. You could try adding the IPs directly to /etc/csf/csf.deny file (one IP per line with an optional comment after the IP) and then restart csf with csf -r I ...


4

I'd take a different approach... No, I wouldn't mess around with nice for this. And gzip isn't that great. Plus, you're using gzip -9 which gives the greatest compression rates at the expense of CPU. Do you really need that level of compression over the default (level 6)? Does your system get strained as much if you don't use gzip level 9? What are the ...


6

There are caveats to pay attention to. Since the question doesn't specify an exact OS (but implies it is some Unix like OS), the list of caveats will depend on specific OS and version. The most important to keep in mind are: nice is intended to affect how much CPU time is given to a process, but not how much RAM or I/O capacity. Thus instead of the intended ...


2

In addition to the ampersand that was already mentioned, you also have to be careful with a % character in a cron entry. % in a cron entry will be interpreted as a line break and has to be escaped with a backslash(\%). Make sure the import_key that you censored doesn't have such a character. Also, URLs often have % in them to escape certain characters like ...


2

The ampersand character (&) actually means something in Linux (well, in a Bourne-compatible shell). It means: run the command as a background task. Because of that, you are actually telling cron to run /usr/bin/wget -O /dev/null http://domain.nl/wp-cron.php?import_key=XXXXXXXXXX in the background, and then to do action=processing. And that's what cron ...


0

Have you tried turning the service off then back on again? I came across a similar issue not too long ago configuring a backup script for our wiki server. You have to restart the service to get it to load the new configuration, so if you haven't already, try that. service cron restart or /etc/init.d/cron restart


0

I know this is a bit late, but I found this when searching for this issue on Google so maybe it may help people. While running munin-check doesn't report any errors, what I found by entering into a shell as munin, is that the permissions of the parent directories to the munin stats html folder were wrong. Try entering a shell as munin and then entering into ...


1

I think the nearest one should be: * * * * * /usr/local/php -q /home/user_name/public_html/run.php Notes: All need absolute path You need to find your php's absolute path by command which php. Mine is /usr/bin/php You need to make sure you are editing the same user's crontab with crontab -e, and the same user can do a cat ...


0

Try piping the remote command into the ssh. If that seems to make a difference you may have better luck to do some magic with expect. echo remote command | ssh user@host


2

If the script is running in root's crontab, you should remove 'sudo' from the command. I've seen this before, where trying to 'sudo' when you're already root makes the command fail. If you want to switch user, then the command when run as root, is 'su -l jira', not sudo -u jira.


6

It appears that some checks that weren't supposed to be released into all update streams have been. See eg http://unix.stackexchange.com/questions/183763/spamassassin-object-method-location-problems-after-restart for more details, but that the upshot is that the errors should go away following the next update after the errant rule(s) have been pulled. ...


0

Although it's not the prettiest solution and although I would suggest you against using it, what you can do is: 11 9 * * * bash -ic "test-alias > /root/tmp.output 2>&1" This will run bash as interactive shell (-i) and will thus read bashrc. To make sure .profile is sourced, you need to have this block in your .bashrc: [ -f ~/.profile ] ...


0

You can use following line to run every 5,15,25,35,45, and 55th minutes 5-55/10 * * * * sh foobar.sh This works Vixie cron which is default cron in most of operating systems.



Top 50 recent answers are included