Tag Info

New answers tagged

0

*/150 * * * 0,6 gnome-session-quit Works fine.


0

How about the following: crontab -l | some-editing-command | EDITOR=cat crontab -e The first part of the pipe lists the current crontab, the second part is supposed to modify it in a sensible way, and the third part reinstalls it using cat as the "editor", as suggested by @muru.


2

To install a crontab: echo "1 1 * * * test" | crontab - should do the trick. NOTICE that this substitutes the whole crontab. You have to save the value it had with crontab -l if you just want to add/edit things. For example (crontab -l && echo "1 1 * * * test") | crontab - will add the line to your crontab.


0

Using user84207 and Loony answers: Create 2 scripts: startDropbox.sh: dropbox start stopDropbox.sh: result=$(dropbox status) if [ "$result" = "Up to date" ]; then dropbox stop fi Add in crontab, with crontab -e # starts only after each 5 minutes */5 * * * * startDropbox.sh # try to stop every minute */1 * * * * stopDropbox.sh


4

3 * * * * /root/dothis.sh does not run a script every three minutes, it runs a script on the third minutes of every hour (00:03, 01:03, ...). To run a script every three minutes, the syntax is: */3 * * * * /root/dothis.sh


1

nmcli uses DBus, so you could try using dbus-launch as shown in this answer. It would look like: dbus-launch --exit-with-session nmcli dev disconnect iface eth0 Apparently, this only works for the root user. The other way is more direct: sudo ip link set down dev eth0 Used in root's crontab, or in /etc/crontab, the sudo wouldn't be required.


0

I just followed this answer from How to Setup a root cron Job Properly: If you want to run a script as a normal user: crontab -e And add the line: 07,37 * * * * /usr/bin/tunlrupdate.sh If you want to run your script as root: sudo crontab -e And add the same line: 07,37 * * * * /usr/bin/tunlrupdate.sh As the user and it worked ...


0

Don't forget that these cron scripts are run as root, which means that for example the home directory refers to root's home directory, and so on. Since your script asks for a password, you probably need to run it with root privileges so you can't just create the usual .anacron/cron.daily and put your script in there, you have to use /etc/cron.daily so it ...


1

You could use a single cron entry with @reboot, and use a script to select the command. For example, in crontab: @reboot bash /path/to/my/script.sh And in /path/to/my/script.sh: #! /bin/bash case $(date +%u) in 1) echo Monday command 1 ;; 2) echo Tuesday command 2 ;; # ... 7) echo ...


0

The best thing to do is to file a bug and once you have a bugtracking number, ask a new question and ask whether anyone else has this problem and ask them to file a bug against your bug so that it "affects multiple users" and then it will be solved (probably by putting "none" in PRUNEFS as a standard... Fair warning: filing a bug is a lot of work, so that's ...


0

Figured it out. The email was being sent because I had some lines of System.out.println() The logfiles were being created, just in the wrong place. I had to modify the original file line to be: PrintWriter writer = new PrintWriter("/mnt/data/scripts/" + "log" + format.format(date) + ".txt");


0

There is a file that controls system timezone.. I just got the same issue, here is the solution: If you haven't configure manually any timezone, performing "date" should display UTC time. create a backup sudo cp /etc/localtime /etc/localtime.bkp remove the file: sudo rm /etc/localtime I live in Chicago, (you may need to change the path, using tab ...


1

So, I just set the environment variable XDG_RUNTIME_DIR the same as in my working shells, and it works. I found this page because I had this same issue with trying to get sound to play from cron jobs -- mpg123 seeming to think it plays the file fine, but with no audio. Setting that variable fixed it.


2

Let find do the hard work for you. Write a script that processes a file passed as the first parameter, then do this in your crontab: find /wherever -iname 'fedex*.xls' -exec your-script "{}" \; find will not generate any output if it doesn't find files matching the expression.


0

Why not use the find command, putting a single filename on each line: for fullfile in $(find <dir> -name '*.xslx'); do # fullfile now contains the full filename, including any spaces # process to your heart's content, using double quotes (") around $fullfile to # make sure the spaces are kept intact cp "$fullfile" /new/directory/ end ...


2

Your 1st line wont work; numbers need to be in sequence. You can always use 2 lines: 1 from 13:00 up to 24:00 and one from 00:00 to 03:00. 37 00-03/2 * * 1-5 php /home/code/mytest.php 37 13-00/2 * * 1-5 php /home/code/mytest.php You can write out all the hours comma separated. 37 13,15,17,19,21,23,01,03 * * 1-5 php /home/code/mytest.php (I hope I ...


1

$ if ! ls /tmp/*.bla >/dev/null 2>&1 ; then echo "no meat" ; else echo "have a steak" ; fi no meat $ touch /tmp/a.bla $ if ! ls /tmp/*.bla >/dev/null 2>&1 ; then echo "no meat" ; else echo "have a steak" ; fi have a steak


2

Python seems a comfortable option as well if I am not missing the point: #!/usr/bin/env python3 import subprocess import os myfullpath = "/home/jacob/Bureaublad" files = [f for f in os.listdir(myfullpath) if f.endswith(".xlsx")] for f in files: cmd = "gedit" subprocess.check_call(["/bin/bash", "-c", cmd])


1

If you're dead-set on using ls anyway, despite it's unsuitability for your original code, or if you: just want to find out if ls didn't find any files you could check it's exit code. A "No such file..." will fail (exit code 2). While even an empty directory's ls will succeed (exit code 0): $ ls *.xls ls: cannot access *.xls: No such file or directory $ ...


1

If you look at http://stackoverflow.com/questions/2937407/test-whether-a-glob-has-any-matches-in-bash, something like that should work: cd "$myfullpath/input/" if test -n "$(shopt -s nullglob; echo fedex*.xlsl)" then for file in fedex*.xlsl do fullfile="$myfullpath/input/$file" # things done fi ... Look also at ...


7

First things first: Don't parse ls. Now that we have got that out of the way, use globbing, alongwith nullglob: shopt -s nullglob for fullfile in "$myfullpath"/input/fedex*.xlsx do #....... done Usually with globbing, if * doesn't match anything it's left as is. With nullglob, it is replaced with nothing, so a false match isn't triggered. For example: ...


1

FIXED, Needed full path, enscript --language=html -p/home/adminuser/Backup_Cakebox_Server.html /home/adminuser/Backup_Cakebox_Server.log enscript /home/adminuser/Backup_Cakebox_Server.log -o - | ps2pdf - /home/adminuser/Backup_Cakebox_Server.pdf ...sorry for this unnecessary posting....


0

You need to set the DISPLAY environment variable before calling it, you can try this in the virtual consoles (Ctrl-Alt-F1) since they don't have the DISPLAY variable set, they will act exactly like the cron script will act. DISPLAY=:0 xprintidle or export DISPLAY=:0 xprintidle either should work.



Top 50 recent answers are included