Hot answers tagged

24

Process tree While the process is running try to use ps with the f option to see the process hierarchy: ps axuf Then you should get a tree of processes, meaning you should see what the parent process of the gzip is. If gzip is a direct descendant of init then probably its parent has exited already, as it's very unlikely that init would create the gzip ...


5

How are you using cron -m? Are you passing it a script that sends mail to a group of people? If so, why not just put MAILTO=cron-people in your crontab, and define cron-people as a mail alias? Then you can just update that alias as necessary.


4

In general, rather than editing /etc/crontab directly, it's easier to use the crontab command. The syntax to change a non-root user's crontab varies slightly from platform to platform. For example on Red Hat Enterprise Linux, it would be: # crontab -e -u alex On AIX, HP-UX and Solaris: # crontab -e alex You may also need to add that user to cron.allow ...


3

Just an add-on for Rahul Patil answer. Using his answer, I have achieved the required result the following way: * * * * * /path/of/myscript.sh * * * * * sleep 20s && /path/of/myscript.sh * * * * * sleep 40s && /path/of/myscript.sh This allowed me to execute the script 3 times per minute.


2

You will have to give absolute paths in your script, cron might run your script somewhere else, not in your $HOME. You probably haven't got the venerable mail(1) program installed. And if you have, for sanity's sake, also give full paths to any executables your script runs. In general, for any script that runs with extra privileges (as another user, ...


2

The % symbols are special in a crontab entry, so you can't use them directly in your date format string. man 5 crontab writes The sixth field (the rest of the line) specifies the command to be run. The entire command portion of the line, up to a newline or % character, will be executed by /bin/sh or by the shell specified in the ...


2

First, to debug and monitorize this, as a rule of thumb, add a MAILTO variable in the crontab, should a problem arises in the standard error, it emails you. # crontab -e MAILTO=mymail@mydomain.com 30 3 * * * /usr/local/bin/blahblah.sh Also notice if the command outputs something in the standard output you can redirect it to null if you don't want that in ...


2

The moreutils package contains a program chronic for this purpose. You just call it like chronic my_program args ... Very handy in cron jobs.


2

This was resolved in this bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1298192 Please make sure you have the latest kernel: 4.3.3-301


2

Here are a few tricks that can help you figure out what's going on: Get the offending process's PID: $ pgrep -a gzip 25267 gzip -c --best file On my system (where I've launched a big gzip job), that returns the single PID: 25267. You might have more than one so, make sure to choose the right one. The -a flag tells pgrep to print the full command line, ...


2

The format seems to be correct (after correction applied posted in the comment above). Are there some special restrictions for having everything in a single line? In case you need to have everything in a single line, I would suggest to change the shell script to avoid Fridays 2-9am, eg #!/bin/bash # THIS CODE IS NOT TESTED # skip on fridays 2-9am # what ...


1

If you want to move it from daily to monthly run, you need to use mv and not cp as otherwise you would simply add a monthly run. sudo mv /etc/cron.daily/0yum-cron /etc/cron.monthly/0yum-cron should do what you're asking for.


1

If you have a script that runs properly when run from the command line in a shell but will not execute from cron, you might have a problem with the environment that cron is running in. Try appending: 2> /tmp/error.txt To the end of your statement that won't execute in cron to see what errors are happening during execution. Run the command with ...


1

Per terdon's request, I am posting this comment as an answer, so that the question can be marked as "answered" Instead of relying on script logging, especially if this will eventually be a cron job, consider sending output and error messages to one or more designated files(s) in your php code. When you run it in cron, it will create a session log ...


1

pstree provides a nicely formatted output displaying what spawned what (assuming the parent does not die immediately after spawning the gzip command) Also check out Is there an easy way to log all commands executed, including command line arguments?


1

1) The error pretty much speaks for itself: your script cannot find the mail binary. Either it isn't installed, or it is but isn't in your $PATH and therefore you have to call it specifying the full path (e.g. /usr/bin/mail). 2) You do not need to attach a timestamp manually to the payload passed to mail, as e-mail messages bear already a timestamp in ...


1

Use a sub-shell to limit scope: 0 0 * * 0 (export PATH=$PATH:/sbin; /etc/init.d/tic_minus restart)


1

It turned out that the issue lay with mailx's pager setting. It began using more for some reason, when previously it had used less (which does the escaping). Linking more to less again restored the old behavior.


1

You could pipe the output through tr before processing it further or sending it. ./your-script | tr "\r" "\n" | mail This should replace all carriage return characters with line feeds. The same would be possible within the crontab: * * * * 2 /path/to/your-script --args | tr "\r" "\n"


1

Quoting 'TNW' When find figures out how many 24-hour periods ago the file was last accessed, any fractional part is ignored, so to match -atime +1, a file has to have been accessed at least two days ago. So to find a file that is only a day old, you can use either of the snippets below find /home/backups/* -mtime +0 or find . -mmin +$((60*24))


1

The main thing to realise is that anacron is designed to complement cron; you should really just configure jobs in /etc/cron.daily, /etc/cron.weekly or /etc/cron.monthly. anacron is not designed for jobs that run more frequently; its main purpose is to allow daily, weekly or monthly jobs to "catch up" on computers which aren't on all the time. anacron uses ...



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