Tag Info

Hot answers tagged

4

Run the rpm command with sudo: #!/bin/sh mkdir -p /data/workday/cred chown -R myuser:myuser /data sudo -u myuser rpm -Uvp --force --nodeps --prefix /data/place /data/RPMs/myrpm.rpm


3

You can try to return the name of the parent process with something like this: - ps -ocommand= -p $PPID | awk -F/ '{print $NF}' | awk '{print $1}' For me this returned konsole when I ran this interactively. or you could script in some logic to handle situations. while getopts cm opt do case $opt in c) ## Do crontask ;; ...


3

The process ID is off by one because you have put an extra & after the $javaCommandLine. In other words, you have put two processes in the background before calling echo $!, thus getting the PID of >>$serviceLogFile 2>&1 rather than $javaCommandLine. Those two pieces should be put in one, as the old 2 line codes shows su ...


2

there is no universal way at all. using interactive/noninteractive shell detection or tty detection is not reliable either, as other cases than cron can have these characteristics. just add a variable in your cron entry. say you need to run test.sh, then use this instead. $ RUNENV=cron ./test.sh cron cat ./test.sh #!/bin/sh echo $RUNENV This is fairly ...


1

ntpdate is depreciated. You should install the NTP client and configure the ntpd daemon configuration file /etc/ntp.conf: # cat /etc/ntp.conf | grep -v ^# | grep -v ^$ driftfile /var/lib/ntp/drift restrict default kod nomodify notrap nopeer noquery restrict -6 default kod nomodify notrap nopeer noquery restrict 127.0.0.1 restrict -6 ::1 server ...


1

I have no idea why you (and I get the same problem) can't capture the output of the command when run from rc.local. If you want to capture it you can do something like out=$(ntpdate ntp.fudan.edu.cn 2>&1) echo $out >>/data/logs/1.log which just worked on a system I have to hand.


1

I don't know how portable this is, but on Linux you can run tty and check whether the output is a tty. $ tty /dev/pts/2 $ crontab -e * * * * * echo $(tty) >> /home/paulo/cron_tty [Wait a minute...] $ cat /home/paulo/cron_tty not a tty Note that the tty will also not be set if the script is running non-interactively from something other than cron, ...


1

The stall occurs while dirty pages are being written to disk; you can get a quick introduction to the problem at this LWN article. Basically, the current default for the amount of memory used to cache writes is way too high. Try setting */proc/sys/vm/dirty_background_bytes* to 104857600 and */proc/sys/vm/dirty_bytes* to 209715200. You can do this for the ...


1

This answer functions in a way which avoids you having to manipulate the dirty_bytes/dirty_background_bytes system global which may affect other applications when not doing a backup. Its a bit of a hack to be honest, but I leave it in case its useful to you. tar -zcv --one-file-system \ --exclude=/run \ --exclude=/tmp \ --exclude=/home \ ...


1

su starts a shell. When you exit that shell, then the rpm command will execute. If you're changing user to execute the rpm command, then su -c 'rpm -Uvp --force --nodeps --prefix /data/place /data/RPMs/myrpm.rpm' myuser



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