Tag Info

New answers tagged

6

Option 1 Schedule your job in cron to run every hour (or every other hour), but prefix the job with something like this (presuming you have SHELL=/bin/bash in your crontab): [ $[RANDOM % 12] -eq 0 ] || exit 0; YOUR_JOB_HERE Then there will be an approximately* one in twelve chance of the job running each time its scheduled. Option 2 Schedule a cron job ...


8

You could use the command 'at' at now +4 hours -f commandfile Or at now +$((($RANDOM % 10)+2)) hours -f commandfile


0

To formalise and expand on what someone said in a comment, when you put something in root's crontab it will run inside /root, not in the directory the script is in, because cron doesn't even know where that is. Because your backup files aren't in that directory tree, the find command never reaches them. So the job is running, it just never finds any files to ...


0

If you already have a cron which is not dcron and don't want to change it, you can use this cron job: 0 8 * * wed n=0 && [[ -e /home/user/.cronjob && -r /home/user/cronjob ]] && read n < /home/user/.cronjob ; [[ $n == 0 ]] && your_actual_job ; echo $(( (n+1) \% 3 )) > /home/user/.cronjob This will do a sort of ...


1

Execute the following every Wednesday: [ -f /path/to/timestamp ] && \ [ `date +%s` -lt $(($(cat /path/to/timestamp)+20*86400)) ] || \ { date +%s > /path/to/timestamp; your_command; }


1

If you use GNU/Linux and dillon's crond (look for a package called dcron for your distribution), you can use crontab's finer-grained syntax, as explained in man 1 crontab 0 8 * * wed ID=job1 FREQ=20d your_job This will execute your_job on wednesday, at 8 am, if at least 20 days have elapsed since last execution.


2

cron by default running in a minimal environment, from man 5 cron: Several environment variables are set up automatically by the cron(8) daemon. SHELL is set to /bin/sh, and LOGNAME and HOME are set from the /etc/passwd line of the crontab's owner. PATH is set to "/usr/bin:/bin". HOME, SHELL, and PATH may be overridden by settings in ...


0

For closure, this is the start of the script I am going to use. It needs more work to make it robust and do logging but you should get the general idea. #!/bin/sh # This script should be executed from a crontab that executes every 5 or 10 minutes # the find below looks for all log files that do NOT have the sticky bit set. # You can see the sticky bit ...


0

Try to use inotifywait for that: inotifywait -e close_write /home/tomcat/openam/openam/log/CURRENT_OPENED_LOG_FILE


0

This is a well known issue. You need to explicitly set the shell and all the environment variables needed by the script called by cron.


1

Your line in cron entry includes root and that's not needed, because when you invoke crontab -e it will start to edit cron as current user e.g root. All cron entries are located under /var/spool/cron/<user> so there you can check entries. Also in /var/log/cron you can check cron log with specific messages for cron jobs. So there you can check if action ...


0

Your crontab entry is: 00 11 * * fri root usr/bin/mysqlauditgrep mysqlauditgrep --format=GRID /var/lib/mysql/audit.log The table format is: # m h dom mon dow user command So your command seems to be: usr/bin/mysqlauditgrep mysqlauditgrep --format=GRID /var/lib/mysql/audit.log Which is not valid, there is no leading / and the mysqlauditgrep is ...


0

The cron was not running. After a restart the cron worked, and logrotate started to work as well.


3

Your crontab line should be like this: 00 11 * * fri /usr/bin/mysqlauditgrep --format=GRID /var/lib/mysql/audit.log Type man 5 crontab to check the syntax of crontab file


0

Hello I was hopping someone with better skill could answer. HP-UX has quite an old System V toolbox so you will not have the recent GNU tools. HP-UX posix shell, which is /usr/bin/sh is very close to ksh93. So you can compare the age of two files with [[ file1 -nt file2 ]] wich returns true if file1 is newer than file2. Don't use /usr/bin/ksh on HP-UX it ...


0

Do you want something that monitors a directory? incron can be quite handy for that: 1. Install incron from a repo 2. Enable incrond: sudo systemctl enable incrond.service sudo systemctl start incrond.service 3.Create appropriate incrontab: incrontab -e and add as content: /path/to/watch IN_CREATE /path/to/mylogger.sh $@/$# 4.Create the logger ...


4

You generally want to add a call to an interpreter at the top of your scripts, like so: $cat myfile.sh #!/bin/bash source /pathto/venv/bin/activate python /pathto/rsseater.py This may seem very similar to what you have but is it in fact very different. In your scenario you're attempting to run the commands within the shell that get's invoked when you run ...


3

Specifying a username like mylogin is for the /etc/crontab file. With your command sudo crontab -e you are actually editing /var/spool/cron/crontabs/root and you should not specify a username in such a file, only in /etc/crontab. If you have to run the command as user mylogin you have to put the line in /etc/crontab (and edit this with root privileges), or ...


6

From Wikipedia: Slash ( / ) Slashes describe increments of ranges. For example 3-59/15 in the 1st field (minutes) indicate the third minute of the hour and every 15 minutes thereafter. The form "*/..." is equivalent to the form "first-last/...", that is, an increment over the largest possible range of the field. So 3-59/10 * * * * ~/DoSomeStuff.sh ...


3

If you have to reboot your server every 6 hours, you are probably doing something wrong. If you're doing this because of memory leaks in Minecraft or something like that, you might want to consider only restarting Minecraft, not the whole system. You can send keystrokes to a screen session "from the outside". (Searching really does wonders sometimes…) If ...


0

from: http://www.samba.org/samba/docs/man/manpages/vfs_recycle.8.html recycle:touch_mtime = Yes Specifies whether a file's last modified date should be updated when the file is moved to the repository.


-1

This is working fine for me. 0 3 * * * /opt/appsomething/scripts/mysqlbkp_localserver.sh 2>&1 mail -s "Backup routine from server" root


1

Probably you want to use /etc/cron.d, where you can place full system crontab entries (as you'd put in /etc/crontab) in their own file. Then you can set the intervals, enable, and disable it by manipulating that file.


2

I am considering creating a cron job that will run once a month and remove the oldest characters (closest to the top) from each log file, making each 100 megs of less in size. There are some problems that can arise with this methodology, so make sure first that the logging process is okay and continues to log when you edit a file this way. If it holds ...


1

Use logrotate, it rotates your logs AND compress them for you if you want. Most probably it will already be running on your system, so create a file in /etc/logrotate.d to tell logrotate how to treat your logs. Check the man file for specs...


-1

man split will help you. Especially the -b flag.


1

The dollar sign in your string is being expanded at the time the echo is run and causing command substitution to happen then. What you want is to pass that string AS A STRING on to the file. There are two ways you can keep the substitution from happening. You can escape the dollar sign: /bin/echo "0 0 * * 1-5 ../..backup-\$(date +%Y-%m-%d).log" You can ...



Top 50 recent answers are included