Tag Info

Hot answers tagged

19

Assuming you can't just log in and add it to that user's crontab, put a file in /etc/cron.d. It should be formatted as a normal cronjob, but with an extra field. Before the command to run and after the timing, put the user. You should be able to find examples already on your system. Example: #<timing> <user> <command> 11 * * * * root ...


11

As Ignacio said, /etc/crontab is the system wide crontab. The format of /etc/crontab is like this: # m h dom mon dow user command * * * * * someuser echo 'foo' while crontab -e is per user, it's worth mentioning with no -u argument the crontab command goes to the current users crontab. You can do crontab -e -u <username> to edit a ...


5

This is an FTP sample script to transfer one file: (Note you can use an FQDN instead of IP) #!/bin/bash # $1 is the file name for the you want to tranfer # usage: this_script <filename> IP_address="xx.xxx.xx.xx" username="remote_ftp_username" domain = sample.domain.ftp password= password ftp -n > ftp_$$.log <<EOF verbose open $IP_address ...


5

To display something on an X server the X client (like vlc) requires an environment variable DISPLAY to be set which defines network address of the X server. In almost all cases (one local X server) it should be assigned to :0. You can set that variable from your script or just run bash -c "DISPLAY=:0 vlc $vlcopts" instead (of course replacing $vlcopts).


5

Yes those are the same. From the man page (man 5 crontab): A field may be an asterisk (*), which always stands for ``first-last''. [...] Ranges can include "steps", so "1-9/2" is the same as "1,3,5,7,9". Therefore */x means the whole range (depending on the position of the *) covered with steps of x. In your case, for the "hour" position, the ...


4

If you used crontab -e instead of dropping a file in /etc/cron.d, your line has too many fields. You only specify the user in the latter case. Removing the username from your crontab, it should look like this: */1 * * * * /usr/sbin/ntpdate ptbtime1.ptb.de >> /var/log/ntpdate.log Syntax errors would have been written into /var/log/cron.log; it's ...


4

You want something like anacron: anacron is a computer program that performs periodic command scheduling which is traditionally done by cron, but without assuming that the system is running continuously. Thus, it can be used to control the execution of daily, weekly, and monthly jobs (or anything with a period of n days) on systems that ...


4

You should send successful email notifications to /dev/null so they disappear. But you want to see unsuccessful email notifications. This means you need to first direct stdout to /dev/null and then direct /dev/stderr to stdout try changing the redirection part of your cronjobs to >/dev/null 2>&1 See this link


4

When you enter commands in your crontab, you don't need to specify the user, as each user has their own individual crontab stored in /usr/lib/cron/tabs/ Your crontab should look like the following: * * * * * /sbin/ifconfig en0 down > /dev/null 0 19 * * * /sbin/ifconfig en0 down > /dev/null 0 7 * * * /sbin/ifconfig en0 up > /dev/null


4

Stick this at the top of your cron job script (modified as you need)... if [[ $(date +%u) -eq 7 && $(date +%H) -eq 16 ]]; then echo "I don't run at this time" exit 1 fi echo "Something to do at other times here..." The first instance of "date" returns the day of week (Sunday = 7), the second returns the hour (16 = 4.00pm - 4.59pm). If the ...


3

What you really want to do is look at setting up public keys between the servers so they 'trust' each other and passwords are not needed. Have a read here: http://www.thegeekstuff.com/2011/07/rsync-over-ssh-without-password/ http://blogs.oracle.com/jkini/entry/how_to_scp_scp_and


3

(Copying my comment as an answer, since it turned out to be the solution; I guessed right.) So cron jobs are being scheduled in UTC (Europe/Paris is at a one hour offset from UTC). The Vixie cron man page says: The daemon will use, if present, the definition from /etc/timezone for the timezone. What's in /etc/timezone? Have you modified ...


3

If the first day of the month is a Sunday it will indeed run. The reason is that the two conditions "day of month" (third field) and "day of week" (fifth field) are not connected with an AND (both must occur) but with an OR (either one must occur). From man 5 crontab: Note: The day of a command's execution can be specified by two fields -- day of ...


3

You could use forfiles to enumerate and process files not modified longer than (or since date), for example (as shown on linked MS page - this would simply list them) forfiles /s /m *.* /d -365 /c "cmd /c echo @file is at least one year old." After you've verified it works as you'd want it to, put it in a batch file and schedule using Task Scheduler (or ...


3

If you want the cron job to run every two minutes, it should be /2 * * * * /bin/date >> /home/jon/date_from_cron.txt http://www.adminschoice.com/crontab-quick-reference EDIT: Possibly try */2 * * * * /bin/date >> /home/jon/date_from_cron.txt


2

Put the credentials into a file that has restricted read access. Unless your cron tables already have similarly restricted read access. As grawity noted, putting the credentials into the crontab can result in them leaking to logs and/or email. Thus, it should be strongly discouraged and they should be properly protected inside a file.


2

ps ax|grep cron The error you get is because of the - in the ps command is not needed It depends a bit on which version of ps you are using, on RHEL man ps says: This version of ps accepts several kinds of options: 1 UNIX options, which may be grouped and must be preceded by a dash. 2 BSD options, which may be grouped and must not be used with ...


2

These are not errors. They are status reports. You get these because your cron job generated output. If your cron job has output then cron will mail this output. Either to the person specified in the variable MAILTO. If no one if specified, then the output will be mailed to the owner of the process that produced the output. (In this case: you). If you ...


2

Some distros such as Fedora provide a mechanism where you can set CRON_TZ= to override your default timezone. From the Fedora man 5 crontab The CRON_TZ variable specifies the time zone specific for the cron table. The user should enter a time according to the specified time zone into the table. The time used for writing into a log file is ...


2

You can also use: @hourly screen -d -m vlc-wrapper /path/to/file/foo.flv --novideo --volume 700 --repeat --rc-fake-tty To make vlc work. There is a detailed process here: http://michaelchrisco.com/wiki/index.php?title=Set_up_VLC_as_a_cron_job


1

It sounds like an environment difference between your local shell and the environment created by the cronjob. Create this script in /tmp/env-test: #!/bin/bash env echo $PATH type -a svn cd /path/to/local/workarea svn info Make it executable, run it manually then put it into cron with its output saved: 1 11 * * * /tmp/env-test 2>1 ...


1

No experience here with VixieCron or Anacron; if you're using one of them, try Paul Tomblin's answer. If you're not, you could set up a shell script something like the following: FLAG_FILE="alternate_monday_flag_file" if [ -e $FLAG_FILE ] then # Replace this comment with a call to the script you really want to run chmod u+w $FLAG_FILE rm $FLAG_FILE ...


1

The Unix/Linux cp command uses filesystem paths, not URLs. If the two domains are served from the same server, and you have admin access to the whole server (it is not hosted by a hosting company) you can do the copy by converting the URLs to filesystem paths by prepending the document root "docroot" for each site to the path portion of the URL. If the ...


1

This page explains how to run a GUI app using cron: To run GUI application using cron in the command section replace the command name part the following way env DISPLAY=:0 gui_appname The env DISPLAY=:0 portion will tell cron to use the current display (desktop) for the program "gui_appname". For example to run the rtorrent client(A ...


1

Wikipedia says Most cron implementations simply interpret crontab entries in the system time zone setting under which the cron daemon itself is run. This can be a source of dispute if a large multiuser machine has users in several time zones, especially if the system default timezone includes the potentially confusing DST. Thus, a cron implementation may ...


1

I believe yes. Linux Crontab Format: MIN HOUR DOM MON DOW CMD Pratical examples: Cron and Crontab usage and examples. Cron Job Examples.


1

You can create these files with dd command like below: dd if=/dev/zero of=/tmp/ZeroFile count=10000 bs=200000 dd if=/dev/urandom of=/tmp/UrandomFile count=10000 bs=200000 and for scheduling this jobs with cron you have to put this command in your cronjob: crontab -e write it: 0 */2 * * * /path/to/your/command


1

Can you run after the half hour instead of before? If so this should work for you... 30/2 * * * * If not you would have to designate each of the minutes you want it to run... 2,4,6,8,10,12,14,16,18,20,22,24,26,28,30 * * * * Not sure if your hourly was supposed to recur throughout the day or not but I assumed so.


1

One thing I have learned is to figure out what the cron environment has access to. This may not be a solution but it could open your eyes to this issue in the future. Have cron execute this command: * * * * * set > /temp/text/file Take a look at it and compare it to that of a normal bash shell. Vastly different and it will cause unseen problems


1

What exactly do you mean by the age of a directory? Time since the creation of its inode? I suggest you use find to identify the directories you want to move. E.g. like this: #!/bin/bash res=0 cd /disk1/data/ find -type d -ctime +1 -print0 -prune | \ while IFS= read -r -d '' i; do if [[ ${i} == */* ]]; then # need to ensure subdir ...



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