Tag Info

Hot answers tagged

8

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


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


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


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

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


3

An easy way is to just create a directory in /tmp and use a symlink: mkdir /tmp/mine ln -s /tmp/mine /home/me/tmp You may want to chmod 700 /tmp/mine to keep it private. If you instead want to mount an actual separate tmpfs directory: mount -t tmpfs -o size=100M tmpfs /home/me/tmp You need root privileges to do this, but normal permissions rules apply ...


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


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


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


2

Make two entries in your crontab (or two files, whichever you prefer). You can't combine those.


1

There is a separate daemon for both. The crond daemon runs your cron jobs and the atd dameon runs the at jobs. You can read the manual pages for both with man at and man crond.


1

Using the @reboot cron keyword, this will execute the specified command once after the machine got booted every time. @reboot rm -rf /dev/tmp/*


1

You have to indicate what to kill: kill -9 $(ps | grep "server1" | grep -v grep | awk '{ print $1 }') You can also use the trick: kill -9 $(ps | grep "server[1]" | awk '{ print $1 }')


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.


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


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.



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