Tag Info

New answers tagged

2

cron doesn't know when a job is going to fire. All it does is every minute, go over all the crontab entries and fire those that match "$(date '+%M %H %d %m %w')". What you could do is generate all those timestamps for every minute from now to 49 hours from now (account for DST change), do the matching by hand (the tricky part) and report the first matching ...


1

Debian has a package for you to take care of dumping, compressing and rotating MySQL data. You can install it with the following command: $ sudo apt-get install automysqlbackup After this daily, weekly and monthly dumps will be placed in /var/lib/automysqlbackup


2

Read the fine manual: man 5 crontab : There you will see that "%" has a special meaning for cron. That is clobbering up your intended command. apart from this this is a very bad way to start a mySQL-backup: Your root-DB-password will appear in the process list viewable for every local user or every user with snmp read access You should not start a ...


1

Mail sent by cron is often considered a spam and called cram (cron spam). It is indeed not useful to receive notification every time command was run and succeeded but it would be good if cron still informed you about errors. You can cronic for this purpose: Cronic is a small shim shell script for wrapping cron jobs so that cron only sends email when an ...


4

The exact mechanism depends on what shell is running in the "terminal session". For the BASH shell, the man page for "bash" says: MAILCHECK Specifies how often (in seconds) bash checks for mail. The default is 60 seconds. When it is time to check for mail, the shell does so before displaying the primary prompt. ...


1

The message sqlplus: command not found gives the answer. Since you have an environment variable ORACLE_HOME set, put this line in your script after exporting ORACLE_HOME: export PATH=$PATH:$ORACLE_HOME/bin I also have a superstition of exporting TNS_ADMIN: export TNS_ADMIN=$ORACLE_HOME/network/admin I don't know if that's strictly necessary.


1

Seems like you updated your post with more information, like Bruce said, that error tells you that ORACLE_HOME path is missing. Update your script to include: export ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1 export PATH=$PATH:$ORACLE_HOME/bin export ORACLE_SID=IMR1 I would still fix this in your cron: # run at 9:45 AM monday thur friday 45 09 * * ...


1

There are a few places that you need to look these days for crontabs: Of course the individual user crontabs residing usually in /var/spool/cron/ this includes one for the user root as well as other users. There is a root only crontab in /etc/crontab. From what I remember it contains references to run-parts directories where files with each task are ...


2

From the cron man page: Cron searches /var/spool/cron for crontab files which are named after accounts in crontabs found are loaded into memory. Cron also searches for /etc/crontab and the files in the directory, which are in a differ- ent format (see crontab(5) ). You have looked at the user crontabs, but I don't think you've examined ...


0

is there some better alternative to this? Yes. Use a proper service manager and junk that /etc/init.d/nagios script. At best, you're using a System 5 rc script in compatibility mode under something like upstart or systemd, in which case you'll not be getting some of the useful service management mechanisms that aren't available in compatibility mode ...


0

I've never seen a cron implementation which has a way to run a job at a random time. It's an odd requirement. As the documentation states, 9-12 is a shortcut for 9,10,11,12, and means every hour from 9 to 12. If you want to run a job at a random time, run the job at the start of the interval, and add a random delay. For example, to run at a random hour ...


2

Get rid of the &. That makes it fork into the background, Upstart thinks the process died, then spawns a new one. Just have the exec line without the ampersand.


3

By default, cron runs commands with a very restricted PATH which would not include your service command. This could be what generates the non-zero return code that leads to the email being sent. Unless specified otherwise in the crontab file, commands are run under the path: PATH=/usr/bin:/bin By contrast, service is generally in usr/sbin which is not ...


-1

You can redirect the output to the /dev/null like following (I do this for my thunderbird applications): 30 05 * * * /usr/bin/thunderbird >/dev/null 2>&1 Or redirect it to the file with >> operations which means append: 30 05 * * * /usr/bin/thunderbird >>/tmp/mycron.log 2>&1 NOTE: You can use full path of the service file ...


3

Running sqlplus from a crontab entry can be frustrating. You get a very sparse PATH variable as the shell that crond forks off does not read the "rc" file. In your ".profile" file do you set ORACLE_HOME? Do you include $ORACLE_HOME/bin in the PATH, and export ORACLE_HOME and PATH? Check that first. Also, I have to note that your code shows the ksh in ...


0

I think a possibility is using the day of the year, such like this: # for odd days test $(((`date +%j` % 2))) != 0 && command # for even days test $(((`date +%j` % 2))) == 0 && command It is tested for Unix and Linux systems.


1

I don't understand what causes the error (maybe it's not GNU tar) but in order to put backup_$TIME.tar.gz in $DESDIR you need this: tar cpzf "${DESDIR}/backup_$TIME.tar.gz" "$SRCDIR"


1

Note, for some systems a % is special in a crontab: from crontab(5) on my system 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 a "%" character, will be executed by /bin/sh or by the shell specified in the SHELL variable of the cronfile. A "%" character in ...


1

Execute the script directly and check if it works. Some of shell environment variables may not be available when the script is running under crontab depending on how you setup the script. Try modifying the script to test if environment variables is the issue: sh --login -c "/usr/bin/mysqldump -hhost -uusername -ppassword databasename > ${BASENAME} ...


1

To make sure the cron daemon is running and honouring the crontab, you could make a small test. Edit your crontab with an entry like this: * * * * * /bin/date >>/tmp/test After a minute check the file /tmp/test. If there is no file, the daemon is most probably not running. If that's the case I would get in contact with the support of the provider. ...


0

You can add a line to your .bashrc file, so that it will be executed after restart and first login: echo "python /home/username/myscript.py" >> ~/.bashrc


1

Ok the easieet way to blobk that log line is to not use cron to launch your script. Have your script re-run itself every 60 seconds instead. then it need only be launched once, eg by /etc/inittab.


1

To avoid showing the password on the command where other users can see it with ps, you should not pass the password in the command. It's why many utilities don't support passwords as command line arguments. Instead store your password in a ~/.netrc file and pass the -n option to curl. For the details of file syntax, I let you see the man of curl.


0

I wasn't able to successfully run smsd on boot but cronjob however saved the day. I just scheduled it to run every 5 minutes. It doesn't really matter if you have the same command every 5 minutes since if the process already exist it will throw an error of: smsd - version 1.4.5 from gnokii 0.6.30 LOG: debug mask is 0x1 Config read from file ...



Top 50 recent answers are included