Tag Info

New answers tagged

0

I assumed that cron was the only way to achieve my goal, but I was wrong because cron is for starting background jobs. Then I tried to create a .desktop file and adding it to Startup Applications and it worked. The file is in ~/.config/autostart and this is what it contains: [Desktop Entry] Type=Application Name=Comprobacion ...


0

As mentioned in another answer, the problem is that invoke-rc.d nginx rotate returns an error stating that the rotate action is not supported. The interesting thing is that service nginx rotate works without issues. My guess is that the invoke-rc.d wrapper doesn't support all the actions the actual nginx init script supports. Changing invoke-rc.d nginx ...


2

What director(ies|y) are you looking to do this in? It is not clear from you script. Try going into the directory1, something like: #!/bin/sh GIT=`which git` REPO_DIR=/home/username/Sites/git/repo/ cd ${REPO_DIR} ${GIT} add --all . ${GIT} commit -m "Test commit" ${GIT} push git@bitbucket.org:username/repo.git master Or you can do a git add --all ...


18

The convention used in the Unix manuals, such as the cron man page from V7, is to capitalize the first letter of utility names when used at the beginning of a sentence, and to use their normal (almost always all-lowercase) spelling within sentences or when they're used in examples. This convention is used even when the utility name is an acronym, such as dc ...


0

I think it is trying to say that curl cannot be found as it is not in PATH. Either use an absolute path, or set PATH in the crontab file.


3

5 * * * * curl http://www.google.com is not a shell command, it's an entry in the crontab file. The crontab file is a text file that contains the description of jobs, with the time specification (here 5 * * * *, meaning every hour at 5 minutes past the hour) followed by the command to execute (here curl http://www.google.com). You need to edit the crontab ...


3

In the document you cited you need to keep reading until you get to the section entitled Configuration. This tells you how to configure your crontab.


0

Pipe the output to ts(1) of moreutils among other such similar utilities, which prefix any input with a time stamp: % (echo hi; sleep 3; echo there) | ts Aug 28 18:52:42 hi Aug 28 18:52:45 there % So assuming you want timestamps on just standard error: ...archive.sh 2>&1 >>.../out.log | ts >>.../err.log Note that this is really ...


0

from bash I use crontab -l | { cat; echo "*/10 * * * * /script/script.sh > /dev/null 2>&1"; } | crontab - Also use this script to add cron entries on remote servers cronok="##"; cronok+=`ssh $host 'crontab -l'`; pattern="reboot.sh" if [[ "$cronok" == *${pattern}* ]]; then echo "found cron at [$host]" else ...


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 ...


1

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


0

I would use at. As in: @reboot echo /root/bin/do_the_stuff | at now + 2 minutes # at assigns it an execution time truncated to whole minutes, # so this means it will execute in 1--2 minutes. ... with the added mentioned caveat that if what you really want is to run it after all other things, you should check how to do that in the init that your OS is ...


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

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 ...


0

It would be something like this: for i in /path/to/*/wp-config.php; do echo "define('DISABLE_WP_CRON', true)" >>$i done Be sure to make backup before doing this!


0

kill -1 is a command that will send a SIGHUP signal, meaning all processes with a pid greater than 1 are signaled. What you need is kill -9 2557. The -9 argument sends a SIGKILL signal to the desired process which ensures that it is killed. Other alternatives if your system has the programs installed: pkill crond killall crond


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 ...


0

You probably have an older version of installed via homebrew. Run this command to see what versions you have: find /usr/local/Cellar/openssl-osx-ca -maxdepth 1 -type d To remove all but latest version of openssl-osx-ca run the following command: brew cleanup openssl-osx-ca Lastly, you probably want to remove your mail messages. If so, run the ...


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 ...


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

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


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

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=""


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 ...


0

You can do 2 things. Put the full path in for sendmail. /usr/sbin/sendmail for example. Put the following commands at the beginning of you crontab: SHELL=/bin/bash PATH=/sbin:/bin:/usr/sbin:/usr/bin


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. ...


0

The environment that cron runs scripts in is very limited. It may not be finding all of the required programs. Capture the environment variables of the shell in which you get a good dump and carry that over to your cron script.


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 ...


0

crontab -u username -l; list all crons for the given user.



Top 50 recent answers are included