Tag Info

Hot answers tagged

27

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


17

As root, to edit the cron of user1: crontab -u user1 -e You can also start your command with: su user1 -c foo bar But often, the scripts themselves reduce their own access when started as root.


16

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

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


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

One is the system crontab and can only be edited by root, and the other is the user crontab and can be edited by a user and exists per user.


4

If you want to find out why it's failing, try logging the output of your backup script: 0 1 * * * /backups/dobackup >& /root/dobackup.log


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

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

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 about: */5 * * * * job.sh > /dev/null 00 16 * * 0 touch /tmp/stopJob.lck 00 17 * * 0 rm -f /tmp/stopJob.lck In job.sh just quit if the file exists: if [ -f /tmp/stopJob.lck ] then exit fi


3

You may want to use one of the wrappers for the programs, that output everything when something goes bad and swallow stdout otherwise. One example might be cronic, just prepend 'cronic' to 'run-parts' e.g.: # m h dom mon dow user command 17 * * * * root cd / && /etc/cronic run-parts --report /etc/cron.hourly where /etc/cronic is a place ...


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

The querylog.log file is saved in the /root directory because that's exactly where you have specified it should be saved. If you want to change its location, just edit the path to your desired location, e.g. /var/www/querylog.log.


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


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

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

typically, i put mine in /usr/local/bin/ (for scripts to be run by more than one normal user) and /usr/local/sbin/ (for scripts which are to be run as root). That way you separate the task that the script does, from cron which just automates launching it. You'll need root to store files there, though.


2

Crontab environment is not the same environment as bash terminal. You need to program commands for crontab seperateley.


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

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


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

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


2

Is streamripper.sh executable (chmod +x /root/streamripper.sh)? Is the streamripper binary in the path? Try to give a full path to it in the script (you get the full path with which streamripper).



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