Tag Info

Hot answers tagged

32

As others have pointed out, cron will email you the output of any program it runs (if there is any output). So, if you don't get any output, there are basically three possibilities: crond could not even start a shell for running the program or sending email crond had troubles mailing the output, or the mail was lost. the program did not produce any output ...


32

You can do this directly from the shutdown command, see man shutdown: SYNOPSIS /sbin/shutdown [-akrhPHfFnc] [-t sec] time [warning message] [...] time When to shutdown. So, for example: shutdown -g 21:45 That will run shutdown -h at 21:45. For commands that don't offer this functionality, you can try one of: A. Using at The at daemon ...


25

I use a simple script with at: #!/bin/bash # email reminder notes using at(1)... read -p "Time of message? [HH:MM] " time read -p "Date of message? [dd.mm.yy] " date read -p "Message body? " message at "$time" "$date" <<EOF echo "$message" | mailx -s "REMINDER" me@gmail.com EOF You could just as easily pipe the $message to notify-send or dzen if ...


18

Depending on how your linux system is set up, you can look in: /var/spool/cron/* (user crontabs) /etc/crontab (system-wide crontab) also, many distros have: /etc/cron.d/* These configurations have the same syntax as /etc/crontab /etc/cron.hourly, /etc/cron.daily, /etc/cron.weekly, /etc/cron.monthly These are simply directories that contain ...


16

In the case of your particular script, neither Myscript nor command D will ever be executed. You've defined a function C, but you aren't calling it. The order of execution is: command B runs to completion. command E runs to completion. If you were to call C, it would run Myscript to completion, then run command D to completion. Everything you invoke in ...


15

On Ubuntu/Debian/Centos you can set up a cron job to run @reboot. This runs once at system startup. Use crontab -e to edit the crontab and add a line like the example below e.g. @reboot /path/to/some/script There are lots of resources for cron if you look for them. This site has several good examples.


14

Yes, that would work. If unsure, you may test it with sleep 15 Ctrl+z fg; echo "it works"


12

That's the way GNU/Linux and other multitasking systems work, they share the processor among the running processes, dot won't have 99%, but 100% during 99% of the time. Each process dominates the processor for a certain period of time. This is handled by schedulers (linux has several schedulers, some just employ the usual strategy, some try to give more ...


12

Cron is used to schedule a job to run repeatedly. What you want is at, which schedules a job to run one-time. For your example you can write: at midnight This will bring up an interactive prompt where you can enter /tmp/script.sh followed by Ctrl+D.


11

The traditional unix command at is usually used for this purpose. e.g. echo 'sudo port install gcc45' | at midnight


11

I think the at command is what you are after. E.g.: echo "mail -s Test mstumm < /etc/group" | at 16:30 This will e-mail you a copy of /etc/group at 4:30 PM. You can read more about at here: http://www.softpanorama.org/Utilities/at.shtml


10

NVRAM WakeUp claims to do it; I've never tried. It may not work on all BIOSes, and if it fails a likely consequence is to overwrite a different critical setting that could make your computer unbootable, so use with caution. If you only suspend the computer, APM tools can set a wake-up time with apmsleep. I've successfully used my laptop as an alarm clock ...


9

Probably depends on the crond you are using. For example, with Vixie-Cron (debian/ubuntu default) you get it for the current user via: $ crontab -l or for another user via $ crontab -l -u juser To get the crontabs for all users you can loop over all users and call this command. Alternatively, you can look up the spool files. Usually, they are are ...


9

ionice [-p] <pids/> For example: $ ionice -p `pidof X` none: prio 0 This means X is using the none scheduling class (best effort) with priority 0 (highest priority out of 7). Read more with man ionice.


8

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


7

Fcron has a lot of additional features over common cronds. For example: set the max system load average value under which the job should be run (quote from the Homepage) Thus, you could use fcron to setup what you want.


7

If you aren't seeing the mails, or if you are spamming root@yourcompany with the errors which can be quite annoying to the people who use that account for monitoring. Try sending the output to Syslog instead: */5 * * * * yourcronjob 2>&1 | /usr/bin/logger -t yourtag Then, wait for the cronjob to run and look for the error in /var/log/messages (or ...


7

You can always explicitly send the job output to a log file: 0 8 * * * /usr/local/bin/myjob > /var/log/myjob.log 2>&1 Keep in mind that this will supercede the mail behaviour that has been mentioned before, because crond iself won't receive any output from the job. If you want to keep that behaviour you should look into tee(1).


7

In echo 'one' > /tmp/a The shell does an open(O_WRONLY) on the pipe and then spawns echo which then does the write("one\n"). The open will block until some other process opens the pipe in RD_ONLY or RD_WR though. And so will the open from your echo two. So at the moment you do more /tmp/a you've got two processes ready to fire that have not opened ...


7

This is 100% normal WRT threading on any and all operating systems. The documentation for your thread library, any examples and tutorials you may find, etc. are likely to make a point of this as it is often confusing to people when they are learning the ropes of threading. Threads are by default (and by definition) not synchronized. This means unless you ...


7

In newer kernels, the Completely Fair Scheduler is used (it replaces the O(1) scheduler of older kernels). The CFS stores the planned task in a red-black tree and uses the spent CPU time amount for the process has run as a key. This allows the scheduler to pick the process with the least amount of run-time (which is stored in the left-mode node of the tree) ...


6

Another typical way to start something at boot on many *nix platforms is (or was, I think this may be starting to loose favor -- see alternatives) to put scripts in a directory which, depending on the particular OS/distribution, might be something like /etc/rc2.d, /etc/rc3.d, /etc/rc/rc3.d, or the like (different distributions use different "run levels", ...


6

The default cron configuration will send you a mail with the output of your program. If this fails, you could try wrapping your failing program in a shell script that ensures that the program does not fail, and you could further log the output. This is a configurable setting on some cron implementations.


6

The generic way to use at is Write a script that does what you want to do. Use the full path for all external commands, log output to a proper log-file or mail it. Test the script. Activate it with at -f YOURSCRIPT -t MMDDhhmm


6

I believe this is a question of timing. top checks CPU state every N seconds. At the moment the check is run, top will have to be active since it is actively checking the state of the system. A nice way of seing this in action is to decrease the update time of top and watch your processes move! As suggested in man top: o The user interface, through ...


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


5

You should get email from crond when the job either fails to run or when the job returns a nonzero exit code. Try typing: $ mailx at the command prompt. mailx(1) is the basic mail reading program on most every Unixlike system. It is very primitive by modern standards, but you can pretty much count on it to always be available. Other, better mail ...


5

There's a standard batch command that does more or less what you're after. More precisely, batch executes the jobs when the system load is not too high, one at a time (so it doesn't do any parallelization). The batch command is part of the at package. echo 'command1 --foo=bar' | batch echo 'command2 "$(wibble)"' | batch at -q b -l # on ...


5

The current Linux task scheduler is called Completely Fair Scheduler (CFS). You should have a look at http://people.redhat.com/mingo/cfs-scheduler/sched-design-CFS.txt for more details. The design is quite complex and in my view not suitable for RTOS. A common technique in realtime systems is rate-monotonic scheduling, because it has strong guarantees if ...


5

That's still the default, yes, though I would not call it the same, as it is constantly in development. You can read how it works with links to the code at http://git.kernel.org/?p=linux/kernel/git/next/linux-next.git;a=blob;f=Documentation/scheduler/sched-design-CFS.txt



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