  The Green-Kubo formula relates the spatial diffusion coefficient to the
stationary velocity autocorrelation function. We derive a generalization of the
Green-Kubo formula valid for systems with long-range or nonstationary
correlations for which the standard approach is no longer valid. For the
systems under consideration, the velocity autocorrelation function $\langle
v(t+\tau) v(t) \rangle$ asymptotically exhibits a certain scaling behavior and
the diffusion is anomalous $\langle x^2(t) \rangle \simeq 2 D_\nu t^{\nu}$. We
show how both the anomalous diffusion coefficient $D_\nu$ and exponent $\nu$
can be extracted from this scaling form. Our scaling Green-Kubo relation thus
extends an important relation between transport properties and correlation
functions to generic systems with scale invariant dynamics. This includes
stationary systems with slowly decaying power law correlations as well as aging
systems, whose properties depend on the the age of the system. Even for systems
that are stationary in the long time limit, we find that the long time
diffusive behavior can strongly depend on the initial preparation of the
system. In these cases, the diffusivity $D_{\nu}$ is not unique and we
determine its values for a stationary respectively nonstationary initial state.
We discuss three applications of the scaling Green-Kubo relation: Free
diffusion with nonlinear friction corresponding to cold atoms diffusing in
optical lattices, the fractional Langevin equation with external noise recently
suggested to model active transport in cells and the L\'evy walk with numerous
applications, in particular blinking quantum dots. These examples underline the
wide applicability of our approach, which is able to treat very different
mechanisms of anomalous diffusion.
