Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Hot answers tagged

5

pkill only exits with a status of zero when "One or more processes matched the criteria". This means if ./run_my_script isn't already running, the first && in pkill -f ./run_my_script && /bin/sleep 15 && ./run_my_script will cause the rest not to run. Using a semicolon rather than an and should work pkill -f ./run_my_script ; /bin/...


3

Short script: #!/bin/sh mail -s "Hi, it's me again" user@host <<'END_MAIL' Hi, Just wanted to say I'm still here. Don't forget to feed the cat. Regards, Me END_EMAIL Cron schedule: 10 * * * * /path/to/script.sh You would write the script, which in this case is really just one single command that sends an email with a particular subject line and ...


3

You would do the scheduling with cron. The schedule would look like 0 8-19 * * * /path/to/script or 0 8,9,10,11,12,13,14,15,16,17,18,19 * * * /path/to/script and the script would look like #!/bin/sh ./notify.sh --text "ricordati di bere" && play /mnt/musica/login.wav && zenity --info \ --text="<span size=\"xx-large\">Time is $...


2

So I tried this and it is working: 00 * * * * /bin/sleep 45 && pkill -f ./run_my_script 01 * * * * ./run_my_script


2

You will not be able to recover the file unless you have a backup to restore it from. For the future, I would recommend a sequence of operations like this vi ~/.crontab # Edit a local file crontab ~/.crontab # Set this file as your crontab file If you get into the habit of only ever editing the copy and not the installed version you ...


1

The point of cron is to run commands without a terminal. That means there is no terminal to output stdout to. That's why it is being mailed. You can discard its output: */1 * * * * echo "hiccup" >> /dev/null 2>&1 You can pipe the stdout of your jobs to a program, e.g. logger to send it to the syslog daemon: */1 * * * * echo "hiccup" | logger ...


1

A cron job specified as 0 */5 * * * script.sh would run as your second option, with four hours between the job at 20:00 and 00:00. You could try using five job specifications: 0 0-20/5 1-31/5 * * script.sh 0 1-21/5 2-31/5 * * script.sh 0 2-22/5 3-31/5 * * script.sh 0 3-23/5 4-31/5 * * script.sh 0 4-19/5 5-31/5 * * script.sh The 3rd field is the day of ...


1

If you want to make a whole new daemon you can help yourself with some samples from cron source code: Link 1 Link 2 Or if you want to create your API to interact with the cron daemon , there is a big chance that has been already made , so just search for the given language and you can read the source and help yourself with some parts.


1

Presuming you use Linux, timeout is the simplest way to do this. 08:00 to 19:00 is 11 hours, so we tell timeout to run the script for 11 hours. timeout 11h /home/username/script Start the job with cron at 08:00 (or manually whenever you wish) and have it killed automatically at 19:00 sharp with another cron entry kill -9 /home/username/script


1

Users can set up systemd timers, basically by creating a service and timer in ~/.config/systemd/user and enabling the timer. There are two main features which are lost by switching from user-defined cron jobs to systemd timers (whether that’s good or bad depends on the situation): systemd services don’t email their results; systemd user timers only run ...


1

exiftool -q -r -if '$MIMEType =~ m{^video/} and $ImageHeight < 1080 and print "$Directory/$FileName\0" and 0' . | xargs -r0 echo rm -f (assuming GNU xargs or compatible). Would remove all videos whose Image Height is less that 1080 pixels (if you removed the echo) in the current directory, recursively. That ...


1

As mentioned in this answer you can use command like this to get the dimentions of videofile: ffprobe -v error -select_streams v:0 -show_entries stream=width -of default=nw=1:nk=1 input.mp4 And this will give you output like 1280 and then you can decide what to do with this video


1

You can't mix a schedule with @reboot - cron doesn't support that. If you want to open a file at Linux startup on a specific date, do this: Write a script (chkdate.sh) that checks the date for a match to (for example) May 2 Use the @reboot spec in cron to run chkdate.sh [EDIT: re chkdate.sh, a script to check today's date against a specific date]: ...


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