Tag Info

Hot answers tagged

32

crontab can install new crontab for the invoking user (or the mentioned user as root) reading from STDIN. This is what happended in your case. grep without any option will generate an error message on STDERR as usual and you are piping the STDOUT of grep to STDIN of crontab which is blank hence your crontab will be gone.


4

How did he terminate the job? Did he type C-c or C-d? If he typed C-d, then it's equivalent to running crontab < /dev/null and you have replaced the user's crontab file with an empty one. On the other hand, if you kill crontab with C-c, then the crontab might have been preserved, but you can easily check that by running crontab -l. All this program ...


3

I could reproduce the phenomenon on Ubuntu 15.04 with the following crontab: * * * * * { echo job 0; } & sleep 5 * * * * * { echo job 1; } & * * * * * { sleep 5; echo job 2; } & I got mails from cron with job 0 every minute, mails with job 1 occasionally (5-6 times in last 10 minutes), no mails with job 2. So it seems cron waits for the child ...


3

Upon further testing, I suspect the & is messing with your results. As you point out, &>/dev/null is bash syntax, not sh syntax. As a result, sh is creating a subshell and backgrounding it. Sure, the subshell's echo creates stderr, but my theory is that: cron is not catching the subshell's stderr, and the backgrounding of the subshell always ...


3

If you want to do it for files only in your current directory: for file in $(ls *.php); do echo "define('DISABLE_WP_CRON', true)" >> $file; done If you want to do it for all php files starting from your current directory: for file in $(find . -type f -name "*.php"); do echo "define('DISABLE_WP_CRON', true)" >> $file; done Or probably you ...


3

Updating /etc/localtime for the system wide time zone setting might fix your problem. I guess KST stands for Korea Standard Time, so you might want to choose /usr/share/zoneinfo/Asia/Seoul for it. You can also run tzselect to know which file in /usr/share/zoneinfo to choose. $ sudo cp /etc/localtime /etc/localtime.orig # for backup $ sudo cp ...


2

The mysqldump command returns nothing, which is piped trough gzip and ends in an empty gzip file. See: $ echo -n "" | gzip -9 > test.gz $ stat -c %s test.gz 20 This results in a file with size 20 bytes. So the problem is the mysqldump command. Since it's root's crontab the script runs with root priviledges. sudo is not necessary. Use it without sudo. ...


2

The ifconfig binary resides in /sbin, which by default is not on the cron path. Use full paths to the commands: if /sbin/ifconfig wlan0 | /bin/grep -q "inet addr:" ; then


2

The main difference between running a script on the command line and running it from cron is the environment. If you get different behavior, check if that behavior might be due to environment variables. Cron jobs run with only a few variables set, and those not necessarily to the same value as in a logged-in session (in particular, PATH is often different). ...


2

redirect stderr into /dev/null host=`uname -n` SSHKey=`ssh-keyscan $host 2> /dev/null` echo $SSHKey >> /root/.ssh/known_hosts


2

I'm not sure why you want to drop the caches every hour - that is going to kill performance. There are a few problems with what you've done: You need to edit the crontab of root, as you cannot write to /proc/sys/vm/drop_caches as a non-root user. Your crontab entry is not correct. It should be: 2 * * * * /usr/bin/free && sync && echo 3 ...


2

With a modern init system (like systemd or upstart), you could just have the init system take care of restarting the script if it fails. If for some reason you're stuck with a legacy system, you could have the script periodically update a flag file (touch /var/lib/myapp/flagfile), and then via cron check if the flag file is older than a certain number of ...


2

Depending on the quantity of the logging information you're expecting to produce, it might be worth using the standard logger tool to write it to the user syslog in /var/log: 1 */8 * * * /path/to/myprog 2>&1 | logger -p user.debug -t 'myprog' Here is an example of the output written to /var/log/debug on my Debian-based system: Jul 31 00:17:09 ...


2

It looks to me like you're creating a Bash script, so take advantage of Bash's trap builtin. For example: #!/bin/bash # vim: ft=sh:tw=75:fo-=t:fo+=rcq:ai: function error_trap() { local -ir __exit_code__=${1:-$?} local __timestamp__ # Reset the ERR sigspec to its original disposition. trap - ERR __timestamp__=$( date --rfc-3339=seconds ...


1

The issue was resolved by putting the path before the CLT iwgetwfobj. Thanks for the help.


1

Instead of piping everything to /dev/null (which may leave you without a clue of what happened if something goes wrong), you can pipe your scripts to log files like this: 30 * * * * backup.sh > ~/logs/backup.log And to stop getting mails, just set the MAILTO variable to an empty string at the beginning of your crontab file: MAILTO=""


1

Summary: If rsync gets data to a disk, it will do so losslessly. However, to be totally sure it actually got data to the disk, you'll need to apply the fsync.diff patch, or call sync <files> afterwards. SSH provides data integrity—you're receiving the same data as you're sending. That accounts for the network. Then, rsync uses the write system ...


1

From 'man openvpn': --ping-restart n Similar to --ping-exit, but trigger a SIGUSR1 restart after n seconds pass without reception of a ping or other packet from remote. This option is useful in cases where the remote peer has a dynamic IP address and a low-TTL DNS name is used to track the IP address using a service such as http://dyndns.org/ + a dynamic ...


1

There are 2 solutions. Either you add #! /bin/bash as a first line in your script or you start your crontab file with the following 2 lines: SHELL=/bin/bash PATH=/sbin:/bin:/usr/sbin:/usr/bin


1

What is cron log saying? Or syslog? If there is error with first part of command then second command (after &&) won't be executed. is script csv-editor.php in your PATH? If it isn't than you should run it with absolute path /x/y/my.script. I'm pretty sure that script isn't in your path, so "/usr/bin/php /x/y/script.php ...." should resolve problem. ...


1

The script run via cron is failing. 20 bytes is the size of an empty MySQL dump.


1

X programs use DISPLAYs to work out what X11 instance to apply the program to. If you are the sole user of your host then most likely your display will be localhost:0 or often abbreviated to :0. you can find your DISPLAY variable by using: echo ${DISPLAY} To tell xclip to use that display, issue the -display command line option, or set the the DISPLAY ...


1

You need to specify the full path to the aws executable: 50 12 * * * /usr/local/bin/aws --version > ~/yolo.swag


1

top doesn't show all processes (at least not the version I use). Normally it just shows the most active processes - as many as will fit in the window. I'm not familiar with FreeBSD - is the cron daemon not named crond? Troubleshooting daemons usually means 1) Check syslog - also check syslog configuration. 2) Read the man page for the daemon and restart ...



Only top voted, non community-wiki answers of a minimum length are eligible